是否建议在URL中使用非ASCII字符? [英] Is it advisable to have non-ascii characters in the URL?

查看:95
本文介绍了是否建议在URL中使用非ASCII字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前正在研究I18N项目.我想知道在URL中包含非ASCII字符会带来什么复杂性.如果不建议这样做,那么有什么其他方法可以解决这个问题呢?

We are currently working on a I18N project. I am wondering what are the complications of having the non-ascii characters in the URL. If its not advisable, what are the alternatives to deal with this problem?

编辑(针对Maxym的回答): 该网站将位于特定国家/地区的本地,我不必担心全世界公众都可以访问此网站.我了解从可用性的角度来看,这确实很烦.与此相关的其他技术问题是什么?

EDIT (in response to Maxym's answer): The site is going to be local to specific country and I need not worry about the world wide public accessing this site. I understand that from usability point of view, It is really annoying. What are the other technical problem associated with this?

推荐答案

可以使用 RFC 3986 建议结合百分比的UTF-8编码:

It is possible to use non-ASCII/non-Latin domain names using IDNA. Further, you can always use percent encoding (like %20 for space) in URLs. RFC 3986 recommends UTF-8 encoding combined with percents:

首先应将数据编码为 根据UTF-8的八位字节 字符编码;然后只有那些 不对应的八位字节 未保留集中的字符 应该是百分比编码的. (...) 为了 例如,字符A将是 表示为"A"的字符 带有拉丁文的拉丁文大写字母A 将被表示为%C3%80",并且 片假名字母A会 表示为%E3%82%A2".

the data should first be encoded as octets according to the UTF-8 character encoding; then only those octets that do not correspond to characters in the unreserved set should be percent-encoded. (...) For example, the character A would be represented as "A", the character LATIN CAPITAL LETTER A WITH GRAVE would be represented as "%C3%80", and the character KATAKANA LETTER A would be represented as "%E3%82%A2".

现代客户端(网络浏览器)可以可以在百分比编码和Unicode之间来回转换,因此该URL以ASCII格式传输,但对用户来说看起来很漂亮.

Modern clients (web browsers) are able to transform back and forth between percent encoding and Unicode, so the URL is transferred as ASCII but looks pretty for the user.

请确保您使用的Web框架/CMS也了解此编码,以简化网站管理员/内容编辑者的URL输入.

Make sure you're using a web framework/CMS that understands this encoding as well, to simplify URL input from webmasters/content editors.

这篇关于是否建议在URL中使用非ASCII字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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