[英]Url encoding PHP
Hey guys, I have question about urlencode and rawurlencode... 大家好,我对urlencode和rawurlencode有疑问...
I tested them out and they produce different result like firefox & some online encoders... 我测试了它们,它们产生了不同的结果,例如firefox和一些在线编码器...
Example; 例;
Firefox & encoders Firefox和编码器
ä = %C3%A4 ß = %C3%9F
PHP rawurlencode & urlencode PHP rawurlencode和urlencode
ß = %DF
ä = %E4
Anyone got some idea except hard-coding and replacing? 除了硬编码和替换以外,有人知道吗?
Cheers 干杯
They produce different outputs because you provided different inputs, ie different character encodings: Firefox uses UTF-8 and your PHP script uses Windows-1252 . 它们产生不同的输出,因为您提供了不同的输入,即不同的字符编码:Firefox使用UTF-8,而PHP脚本使用Windows-1252 。 Although in both character sets the characters are at the same position (
ß
=0xDF, ä
=0xE4), ie the have the same code point, they encode that code point differently: 尽管在两个字符集中,字符都位于相同的位置(
ß
= 0xDF, ä
= 0xE4),即具有相同的代码点,但它们对代码点的编码方式不同:
CP | UTF-8 | Windows-1252
------+--------+--------------
0xDF | 0xC39F | 0xDF
0xE4 | 0xC3A4 | 0xE4
Use the same character encoding (preferably UTF-8) and you'll get the same result. 使用相同的字符编码(最好是UTF-8),您将获得相同的结果。
maybe base64 encode, and use in post, to not make visitors afraid of this URL's? 也许base64编码并用在帖子中,以使访问者不怕此URL? Arsen
阿尔森
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.