URL中的Unicode字符 [英] Unicode characters in URLs

查看:255
本文介绍了URL中的Unicode字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

2010年,您是否会在大型门户网站上提供包含UTF-8字符的网址?


$ b 根据URL上的RFC,禁止Unicode字符(请参阅此处)。他们必须将百分比编码为符合标准。



然而,我的主要观点是提供未编码字符的唯一目的是具有漂亮的网址,所以百分比编码已经结束。

无论RFC说什么,所有主流浏览器似乎都会解析这些网址。然而,我的一般印象是,当离开网络浏览器的领域时,它变得非常不稳定:


  • 将URL粘贴到文本文件中,电子邮件,甚至是具有不同编码的网站

  • HTTP客户端库

  • 异国情调的浏览器,RSS阅读器



我的印象是否正确,因为这里可能会遇到麻烦,因此,如果您服务于非技术类型的受众群体,并且这很重要即使引用并传递了所有链接,您的所有链接都能正常工作吗?



是否有一些以HTML格式提供漂亮网址的神奇方式?

 http://www.example.com/düsseldorf?neighbourhood=Lörick

可以复制+粘贴特殊字符,但在旧客户端重复使用时可以正确使用吗?

解决方案

使用百分号编码。现代浏览器将照顾显示和放大。粘贴问题并使其易于阅读。例如, http://ko.wikipedia.org/wiki/위키백과:대문



编辑:当您在Firefox中复制这样的网址时,剪贴板将保存百分比编码的表单(这通常是件好事),但是如果您只复制其中的一部分,它将保持未编码状态。


In 2010, would you serve URLs containing UTF-8 characters in a large web portal?

Unicode characters are forbidden as per the RFC on URLs (see here). They would have to be percent encoded to be standards compliant.

My main point, though, is serving the unencoded characters for the sole purpose of having nice-looking URLs, so percent encoding is out.

All major browsers seem to be parsing those URLs okay no matter what the RFC says. My general impression, though, is that it gets very shaky when leaving the domain of web browsers:

  • URLs getting copy+pasted into text files, E-Mails, even Web sites with a different encoding
  • HTTP Client libraries
  • Exotic browsers, RSS readers

Is my impression correct that trouble is to be expected here, and thus it's not a practical solution (yet) if you're serving a non-technical audience and it's important that all your links work properly even if quoted and passed on?

Is there some magic way of serving nice-looking URLs in HTML

http://www.example.com/düsseldorf?neighbourhood=Lörick

that can be copy+pasted with the special characters intact, but work correctly when re-used in older clients?

解决方案

Use percent encoding. Modern browsers will take care of display & paste issues and make it human-readable. E. g. http://ko.wikipedia.org/wiki/위키백과:대문

Edit: when you copy such an url in Firefox, the clipboard will hold the percent-encoded form (which is usually a good thing), but if you copy only a part of it, it will remain unencoded.

这篇关于URL中的Unicode字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆