且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Internet Explorer不会从URL中显示汉字

更新时间:2023-01-31 09:18:41

我写了一篇有关 Internet Explorer不显示解码版本的非ASCII字符并使用IRI 解决问题。



截至今天,我们有以下情况:


  1. HTML5支持 IRI ,即 URIs支持Unicode字符

  2. HTTP不支持 IRIs ,但所有主流浏览器都将 IRIs 转换为有效(编码) URIs 以检索指定的资源(页面)。

  3. IE支持锚标签的 href 属性中的 IRIs ,并将其正确显示在它的地址栏就像手动输入你的URL(键盘; - ))

  4. 如果你选择对 IRI 因此使其成为 URI ,IE不会解码该 URI 回到 IRI

所以你可以尝试以下内容:


  1. 使用UTF-8保存HTML文件。这样就可以在其中插入任何Unicode字符。

  2. 不要在HTML页面的链接中对你的URL进行百分比编码。只需使用这样的链接:< a href =http://zh.wikipedia.org/wiki/亦思巴奚兵>亦思巴奚兵乱< / a>

可以在W3C上找到一篇关于该主题的精彩文章:多语言网址简介


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!

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.