php - $_SERVER ['HTTP_REFERER' ] 与 Request.ServerVariables ("HTTP_REFERER")

标签 php asp.net unicode query-string http-referer

如果查询字符串包含非英文字符,为什么 $_SERVER['HTTP_REFERER'] (PHP) 和 Request.ServerVariables("HTTP_REFERER") (ASP) 返回不同的结果?

php 返回正确的值但 asp 不会:

php: сабака

asp: ׁ׀°׀±׀°׀÷׀°

最佳答案

根据 RFC 2616 , 不在 ISO-8859-1 中的字符应进行特殊编码。因此,无论是谁向您发送 header ,似乎都违反了规范。请参阅field-contentTEXT

4.2 Message Headers

message-header = field-name ":" [ field-value ]
field-name     = token
field-value    = *( field-content | LWS )
field-content  = <the OCTETs making up the field-value
                 and consisting of either *TEXT or combinations
                 of token, separators, and quoted-string>

2.2 Basic Rules

TEXT           = <any OCTET except CTLs,
                 but including LWS>

The TEXT rule is only used for descriptive field contents and values that are not intended to be interpreted by the message parser. Words of *TEXT MAY contain characters from character sets other than ISO- 8859-1 [22] only when encoded according to the rules of RFC 2047 [14].

关于php - $_SERVER ['HTTP_REFERER' ] 与 Request.ServerVariables ("HTTP_REFERER"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2942958/

相关文章:

python - Python 中奇怪的前导字符 utf-8/utf-16 编码

javascript - 无法匹配示例表情符号。这可能是什么原因?

php - 如何在 PHP 中回显或打印数组?

c# - 我的类库类中的 StringBuilder html 表

php - 如何在 URL 中转义中文 Unicode 字符?

asp.net - 使用 .Net 2.0 向导控件设计模块化 Web 向导

c# - 在 C# 中存储全局变量(如路径)的位置?

php - 在 PHP 中获取 DomElement 的内部 HTML

javascript - 使用ajax重新格式化从表单发布的php数组

php - 在 PHP 中获取值不为 NULL 的数组的键