Snippets tagged “utf-8”
22 snippets use this tag.
- file_get_contents() Breaks Up UTF-8 CharactersPHP
The file_get_contents() function in PHP is used to read the contents of a file into a string.
- Getting ’ instead of an apostrophe(') in PHPPHP
This can occur if your PHP code is using the ISO-8859-1 character set instead of UTF-8.
- How can I read a large text file line by line using Java?Java
To read a large text file line by line in Java, you can use a BufferedReader and pass it a FileReader object to read the file. Here's an example of how you can do this:
- How can I write a file in UTF-8 format?PHP
To write a file in UTF-8 encoding with PHP, you can use the fopen, fwrite, and fclose functions.
- How to convert Strings to and from UTF8 byte arrays in JavaJava
To convert a String to a UTF-8 encoded byte array in Java, you can use the getBytes method of the String class and specify the character encoding as "UTF-8".
- How to decode Unicode escape sequences like "\u00ed" to proper UTF-8 encoded characters?PHP
In PHP, you can use the utf8_decode() function to decode a string that contains Unicode escape sequences.
- How to Set HTTP Header to UTF-8 in PHPPHP
If you want to learn how to set the HTTP header to UTF-8 in PHP, then read this snippet, examine and run the examples, that are demonstrated in it.
- HTTP POST using JSON in JavaJava
To make an HTTP POST request using JSON in Java, you can use the HttpURLConnection class available in the java.net package. Here's an example of how to do it:
- Java URL encoding of query string parametersJava
To URL encode the query string parameters of a URL in Java, you can use the URLEncoder class from the java.net package.
- PHP json_decode() returns NULL with seemingly valid JSON?PHP
There are a few possible reasons that json_decode() might return NULL when given what appears to be valid JSON.
- Setting the default Java character encodingJava
To set the default character encoding for the Java Virtual Machine (JVM), you can use the -Dfile.encoding option when starting the JVM.
- Unicode (UTF-8) reading and writing to files in PythonPython
To read a file in Unicode (UTF-8) encoding in Python, you can use the built-in open() function, specifying the encoding as "utf-8".
- Unicode character in PHP stringPHP
You can use Unicode characters in a PHP string by including the character directly in the string, or by using the \u escape sequence followed by the Unicode code point of the character in hexadecimal.
- UnicodeDecodeError, invalid continuation bytePython
Here is an example of a Python code snippet that could cause a UnicodeDecodeError: invalid continuation byte error:
- UnicodeDecodeError: 'utf8' codec can't decode byte 0x9cPython
This error occurs when a file or string that is being decoded using the UTF-8 encoding contains an invalid byte sequence.
- UnicodeDecodeError: 'utf8' codec can't decode byte 0xa5 in position 0: invalid start bytePython
This error occurs when trying to decode a byte string using the UTF-8 codec and the byte at the given position is not a valid start byte for a UTF-8 encoded character.
- UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 20: ordinal not in range(128)Python
This error is raised when trying to encode a Unicode string using the ASCII codec, and the string contains a character that is not within the ASCII range (0-127).
- UTF-8 byte[] to StringJava
To convert a byte array to a string in UTF-8 encoding, you can use the following method in Java:
- UTF-8 problems while reading CSV file with fgetcsvPHP
UTF-8 is a character encoding that supports a wide range of characters and is often used for handling multilingual text.
- utf-8 special characters not displayingPHP
This issue is likely caused by a mismatch between the character encoding used by the source of the text (e.g.
- UTF8 Encoding problem - With good examplesPHP
UTF-8 is a character encoding that represents each character in a text document as a unique numerical code.
- Working with UTF-8 encoding in Python sourcePython
Here is a code snippet that demonstrates how to work with UTF-8 encoding in a Python source file: