Url encoding PHP

后端 未结 2 1635
一整个雨季
一整个雨季 2021-01-23 07:36

Hey guys, I have question about urlencode and rawurlencode...

I tested them out and they produce different result like firefox & some online encoders...

Exam

2条回答
  •  不要未来只要你来
    2021-01-23 08:09

    They produce different outputs because you provided different inputs, i.e. different character encodings: Firefox uses UTF-8 and your PHP script uses Windows-1252. Although in both character sets the characters are at the same position (ß=0xDF, ä=0xE4), i.e. the have the same code point, they encode that code point differently:

     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.

提交回复
热议问题