【问题标题】:$_SERVER['HTTP_REFERER'] vs Request.ServerVariables("HTTP_REFERER")$_SERVER['HTTP_REFERER'] 与 Request.ServerVariables("HTTP_REFERER")
【发布时间】:2010-05-31 10:41:37
【问题描述】:

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

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

php: сабака

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

【问题讨论】:

  • 有趣的问题! ASP.NET 是直接引用吗?你是怎么输出的?
  • 如果您使用网络浏览器进行输出,请查看页面属性中的编码/字符集。
  • @Pekka,在 asp 中使用 response.write,在 php 中使用 echo
  • @VolkerK,它是同一个浏览器,我不相信它会为每种技术(php 或 asp)发送差异属性
  • @msony 很可能编码头不同,检查一下,即使只是为了确定。

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


【解决方案1】:

根据RFC 2616,不在 ISO-8859-1 中的字符应进行特殊编码。因此,似乎向您发送标头的人违反了规范。请参阅 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>

TEXT 规则仅用于描述性字段内容和值 不打算由消息解析器解释。仅当根据 RFC 2047 [14] 的规则进行编码时,*TEXT 的字可能包含来自 ISO-8859-1 [22] 以外的字符集的字符。

【讨论】:

    猜你喜欢
    • 2012-09-27
    • 1970-01-01
    • 2017-04-09
    • 2023-03-31
    • 1970-01-01
    • 2016-04-08
    • 2012-04-13
    • 2015-09-06
    • 1970-01-01
    相关资源
    最近更新 更多