Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying UTF-16 characters on web browser

I printed some UTF-16 encoded characters and tried to display it in Firefox and it displayed it as �.

So I went to Tools->Encoding and changed the encoding from UTF-8 to UTF-16 (I also tried changing charset directly in the HTML) However, when I did that, my page was completely flooded with symbols:

਍ℼ佄呃偙⁅瑨汭ാ㰊瑨汭ാഊ㰊敨摡ാ †ഠ †㰠楴汴㹥楬畮⁸‭楆敲潦⁸楤灳慬獹朠牡慢敧挠慨慲瑣牥⁳湩氠敩⁵景眠扥 瀠条⁥‭畓数⁲獕牥⼼楴汴㹥਍††氼湩敲㵬猢潨瑲畣⁴捩湯•牨晥∽瑨灴⼺振湤献瑳瑡捩渮瑥猯灵牥獵牥椯杭是癡捩湯椮潣㸢਍††氼湩敲㵬愢灰敬琭畯档椭潣≮栠敲㵦栢瑴㩰⼯摣⹮獳慴楴⹣敮............

How can web browsers display UTF-16 characters without wrecking the page?

like image 904
allenylzhou Avatar asked Dec 26 '22 15:12

allenylzhou


1 Answers

The “flooded with symbols” excerpt looks like an HTML document that is UTF-8 encoded but treated as if it were UTF-16 encoded. Or it might contain mostly UTF-8 data with some UTF-16 encoded data thrown in, which won’t work.

If you save your data as properly UTF-16 encoded and declare the encoding in HTTP headers and/or meta tags, then some browsers will display it OK, some won’t. Search engines generally fail to process UTF-16, and UTF-16 is mostly not used and should not be used on the web, except by mutual agreement between consenting well-informed partners.

like image 184
Jukka K. Korpela Avatar answered Dec 31 '22 11:12

Jukka K. Korpela