Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internet Explorer does not display Chinese characters from the URL

I am working on a requirement to display (make readable) characters from the URL.

  • When I use Google Chrome, it displays the parameters in Chinese - even though they are encoded to UTF-8.

  • When I use Mozilla Firefox, it displays the parameters in Chinese - even though they are encoded to UTF-8.

  • When I use Internet Explorer, it displays the parameters encoded in UTF-8.

N.B. The URL is encoded to UTF-8; I know that because when I copy the URL from the three of them and paste it to Notepad++ the three of them display the following:

/%E6%89%93%E5%BC%80%E7%9B%AE%E5%BD%95/%E7%9B%B8%E6%9C%BA/%E6%95%B0%E7%A0%81%E7%9B%B8%E6%9C%BA/%E5%B0%8F%E5%9E%8B%E6%95%B0%E7%A0%81%E7%9B%B8%E6%9C%BA/PowerShot-A480/p/1934793

Could it be that Mozilla Firefox and Google Chrome guys have this improvement that can make an encoded String readable and perhaps the IE guys do not support that? Or, is there any way to activate that with IE?

By the way... Going to View >> Encoding >> Unicode (UTF-8) takes care of the text inside of the page but does not make any difference for the text in the URL.

Any help will be greatly appreciated!

like image 439
user1532449 Avatar asked Jan 09 '13 22:01

user1532449


1 Answers

I've written a blog post about Internet Explorer not displaying the decoded version of non-ASCII characters and using IRIs to solve the problem.

As of today, we have the following situation:

  1. HTML5 supports IRIs, i.e. URIs with Unicode character support
  2. HTTP does not support IRIs, but all major browsers take care of converting IRIs to valid (encoded) URIs to retrieve the specified resource (page).
  3. IE supports IRIs in the href attribute of anchor tags and properly displays them in its address bar just like when you enter your URL by hand (keyboard ;-)).
  4. If you choose to percent-encode your IRI thus making it a URI, IE will not decode that URI back into an IRI.

So you could try the following:

  1. Save your HTML files using UTF-8. This allows you to insert any Unicode character into it.
  2. Do not percent-encode your URLs inside your HTML pages' links. Just use links like this: <a href="http://zh.wikipedia.org/wiki/亦思巴奚兵乱">亦思巴奚兵乱</a>

A great article on the topic can also be found at the W3C: An Introduction to Multilingual Web Addresses.

like image 148
Oliver Avatar answered Oct 05 '22 13:10

Oliver