本文介绍了url中的非拉丁符号,php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在网址中使用不允许的字符,例如空格:

If use in url, non allowed character, for example space:

<a href="pa ge.php">link</a>

并点击此链接,在浏览器地址栏中看到 mysite.com/ pa%20ge

and click this link, in browser addres bar I see mysite.com/pa%20ge

好的,如果现在我使用英王乔治一世至三世的字母符号:

okay, and if now I use georgian, (or for example russian) alphabet symbols:

<a href="აბცდ.php">link</a>



在浏览器地址栏中,我看到 mysite /აბცდ。 code>

In in browser addres bar, I see mysite/აბცდ.php

这就是说,这些非拉丁字母符号,没有改变,tey都在url呈现为原始视图。

that is, these non latine alphabet symbols, are not changed, tey are in url "presented" as original view.

问题:为什么?

否,一个URL只能包含ASCII的一部分。

解决方案

浏览器正在将აბცდ转换为发送到服务器的实际网址的百分比编码实体。事实上, 应该将其作为百分比编码字符串嵌入到您的文档中,浏览器只是覆盖了您的错误。

The browser is converting "აბცდ" into percentage-encoded entities for the actual URL that is sent to the server. In fact, you should be embedding it as percentage encoded string into your document to begin with, the browser is just covering that mistake for you.

浏览器在地址栏中显示的内容不同。现代浏览器尝试尽可能方便用户,并解码一些百分比编码字符,以在地址栏中显示为可读的文本。对于反欺骗的原因,只有一些被解码,而不是全部。格鲁吉亚人很安全,因为很难将它误认为任何其他类似的字符。

What the browser shows in the address bar is something different. Modern browsers try to be as user friendly as possible and decode some percentage encoded characters to show in the address bar as human readable text. For anti-spoofing reasons, only some are decoded, not all. Georgian happens to be pretty safe, since it's hard to mistake it for any other similar looking characters.

这篇关于url中的非拉丁符号,php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 13:14