Url编码PHP [英] Url encoding PHP

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

问题描述

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



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



示例;



Firefox&编码器


 ä=%C3%A4 
ß=%C3%9F


PHP rawurlencode& urlencode

 ß=%DF 

ä=%E4


干杯

解决方案

它们产生不同的输出,因为您提供了不同的输入,即不同的字符编码:Firefox使用 UTF-8 ,您的PHP脚本使用的Windows 1252 。虽然在两个字符集中,字符位于相同的位置(ß = 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

ä = %C3%A4
ß = %C3%9F

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆