本文介绍了在browers网址使用非英语字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

/ BG /продукти/ 81-皮肤色调面罩

如何获得这个节目一样,在浏览器的URL路径,而不是

/ BG /%D0%BF%D1%80%D0%为%D0%B4%D1%83%D0%BA%D1%82%D0%B8 / 81-皮肤色调面罩


  1. HttpUtility.UrlEn code(/ BG /продукти/ 81-皮肤色调面罩) - 相同的结果(продукти部分不可读的字符)

  2. HttpUtility.UrlEn $ C $铜镍code(/ BG /продукти/ 81-皮肤色调面罩) - 甚至没有呈现链接正确(怪)

  3. HttpUtility.UrlPathEn code(/ BG /продукти/ 81-皮肤色调面罩) - 相同的结果(продукти部分不可读的字符)


解决方案

 http://www.example.com/bg/продукти/81-skin-toning-mask

时的。

<$p$p><$c$c>http://www.example.com/bg/%d0%bf%d1%80%d0%be%d0%b4%d1%83%d0%ba%d1%82%d0%b8/81-skin-toning-mask

是正确的重新presentation。

两者都是有效的,并会工作得很好作为一个值&LT; A HREF方式&gt; 在现代浏览器

这通常被认为是仁慈旧的浏览器使用URI版本,但是当你做这个IE(怪异)显示在地址栏,而不是漂亮的IRI版本的URI版本,即使是相同的地址和IE浏览器发送相同的请求得到它。还有些人物IE永远不会显示unen codeD(尽管俄罗斯对我的作品)。

所以,如果你更在乎让你的地址栏看起来不错的IE浏览器不是支持旧的pre-IRI浏览器,只写非ASCII字符串直出到页面,只有逃跑了带外ASCII字符。您的网页应该担任UTF-8这在不同的IE设置可靠地工作,但你今天真的一切都应该是UTF-8呢。

/bg/продукти/81-skin-toning-mask

How to get that show like that in browser url path, instead of

/bg/%d0%bf%d1%80%d0%be%d0%b4%d1%83%d0%ba%d1%82%d0%b8/81-skin-toning-mask

  1. HttpUtility.UrlEncode("/bg/продукти/81-skin-toning-mask") - same result (unreadable chars for продукти part)
  2. HttpUtility.UrlEncodeUnicode("/bg/продукти/81-skin-toning-mask") - doesn't even render link properly (strange)
  3. HttpUtility.UrlPathEncode("/bg/продукти/81-skin-toning-mask") - same result (unreadable chars for продукти part)
解决方案
http://www.example.com/bg/продукти/81-skin-toning-mask

Is an IRI.

http://www.example.com/bg/%d0%bf%d1%80%d0%be%d0%b4%d1%83%d0%ba%d1%82%d0%b8/81-skin-toning-mask

Is the correct URI representation of the above IRI.

Both are valid and will work equally well as the value of an <a href> in modern browsers.

It is normally considered kinder to old browsers to use the URI version, however when you do this IE (bizarrely) displays the URI version in the address bar instead of the nice IRI version, even though it is the same address and IE sends the same request to get it. Also some characters IE will never display unencoded (though Russian works for me).

So if you care more about making your address bar look nice in IE than supporting older pre-IRI browsers, just write the non-ASCII string straight out to the page, only escaping out-of-band ASCII characters. Your pages should be served as UTF-8 for this to work reliably over different IE settings, but really today everything you do should be UTF-8 anyway.

这篇关于在browers网址使用非英语字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 14:44