Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UTF-8 encoding on WebView and ICS

To correctly display UTF-8 text in a WebView, I usually use a doctype and a meta tag :

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

and I use a tip I've seen on Stack Overflow:

string = URLEncoder.encode(string, "UTF-8").replaceAll("\\+", " ");

That works fine on Gingerbread and older Android versions, but my Nexus S recently received the Ice Cream Sandwich update, and French characters like é, à, è, etc. are displayed like this: é, for example.

I don't know if the ISO-xxxx-1 encoding is the solution, but if someone had the same problem, please share.

img

like image 381
Sakaroz Avatar asked Dec 20 '11 08:12

Sakaroz


People also ask

What is the difference between UTF-8 and Windows 1252 encoding?

Windows-1252 is a subset of UTF-8 in terms of 'what characters are available', but not in terms of their byte-by-byte representation. Windows-1252 has characters between bytes 127 and 255 that UTF-8 has a different encoding for. Any visible character in the ASCII range (127 and below) are encoded 1:1 in UTF-8.

What is difference between UTF-8 and UTF-8?

The main difference between UTF-8, UTF-16, and UTF-32 character encoding is how many bytes it requires to represent a character in memory. UTF-8 uses a minimum of one byte, while UTF-16 uses a minimum of 2 bytes.

Is UTF-8 the default encoding?

UTF-8 is the dominant encoding for the World Wide Web (and internet technologies), accounting for 98.0% of all web pages, and up to 100.0% for many languages, as of 2022.

Is UTF-8 backwards compatible?

UTF-8 is backward-compatible with ASCII and can represent any standard Unicode character. The first 128 UTF-8 characters precisely match the first 128 ASCII characters (numbered 0-127), meaning that existing ASCII text is already valid UTF-8. All other characters use two to four bytes.


1 Answers

Try using the method loadDataWithBaseURL with random String for the other params instead of loadData

like image 196
Benoit Avatar answered Nov 07 '22 15:11

Benoit