Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php、urldecode()和umlaut-ö;_Php_Urlencode - Fatal编程技术网

php、urldecode()和umlaut-ö;

php、urldecode()和umlaut-ö;,php,urlencode,Php,Urlencode,使用PHP5.3.2,我在处理一个页面请求时遇到了问题,该页面的名称中有一个umlaut: 在testèèu test.htm页面中使用Firefox+Live HTTP头发出请求,我可以看到Firefox在发出请求时自动转换/编码umlaut: GET /test_%C3%B6_test.htm HTTP/1.1 现在,使用我能够在test_öu test.htm和test_%C3%B6_test.htm之间进行编码/解码,所以我认为编码是正确的 使用PHP的urldecode(),我得到t

使用PHP5.3.2,我在处理一个页面请求时遇到了问题,该页面的名称中有一个umlaut:

在testèèu test.htm页面中使用Firefox+Live HTTP头发出请求,我可以看到Firefox在发出请求时自动转换/编码umlaut:

GET /test_%C3%B6_test.htm HTTP/1.1
现在,使用我能够在test_öu test.htm和test_%C3%B6_test.htm之间进行编码/解码,所以我认为编码是正确的

使用PHP的urldecode(),我得到test_195;¨test.htm

被憎恨的404被返回。请注意,文件系统上确实存在testöu test.htm


当我使用javascript的escape()进行测试时,我得到test\u6\u test.htm。当我将其插入浏览器时,我成功地返回了内容页。urldecode()将其转换回umlaut。

您的页面声明为ISO-8859-1,而您的数据是UTF-8编码的。这导致浏览器试图将双字节UTF-8序列0xc3 0xb6解释为两个字符的拉丁-1序列“带波浪号的拉丁大写字母A”“皮尔克罗符号”。您的数据和页面的内容编码需要一致。

urldecode()是单字节,而%C3%B6似乎是多字节。无论如何,为什么不在服务器端对页面名称进行编码呢?或者,更好的是,根本不使用扩展字符。可能重复的是,这基本上是同一个问题-如果愿意,很高兴删除此。感谢您的后续行动-感谢。