`
fff
  • 浏览: 31350 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

php urlencode with charset

阅读更多
<? php
function parseurl($url="",$input_charset,$output_charset)  
{
//1  
$url = rawurlencode(mb_convert_encoding($url, $input_charset, $output_charset));  
$entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D');
$replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]");
//2
$url = str_replace($entities, $replacements, $url);  
return $url;  
} 
>


没有搜到一个通用、完备的解法,只好自己copy修改了个
第一步,编码转换
第二步,反转义

参考资料:http://tuzwu.iteye.com/blog/648214
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics