本文介绍了Url编码PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,伙计们,
我有关于urlencode和rawurlencode的问题...



我测试了他们,并产生不同的结果,如firefox&一些在线编码器...



示例;



Firefox&编码器

PHP rawurlencode& urlencode

 ß=%DF 

ä=%E4


干杯

解决方案

它们产生不同的输出,因为您提供了不同的输入,即不同的字符编码:Firefox使用,您的PHP脚本使用。虽然在两个字符集中,字符位于相同的位置(ß = 0xDF,ä = 0xE4),即具有相同的代码点,他们以不同的方式对代码点进行编码:

  CP | UTF-8 | Windows-1252 
------ + -------- + --------------
0xDF | 0xC39F | 0xDF
0xE4 | 0xC3A4 | 0xE4

使用相同的字符编码(最好是UTF-8),你会得到相同的结果。


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

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

Example;

Firefox & encoders

PHP rawurlencode & urlencode

ß = %DF

ä = %E4

Anyone got some idea except hard-coding and replacing?

Cheers

解决方案

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.

这篇关于Url编码PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 14:30