function parseurl($url="")
{
$url = rawurlencode(mb_convert_encoding($url, 'gb2312', 'utf-8'));
$a = array("%3A", "%2F", "%40");
$b = array(":", "/", "@");
$url = str_replace($a, $b, $url);
return $url;
}
$url="ftp://ud03:password@ud03.kinoko.name/中文/中文.rar";
echo parseurl($url);
//ftp://ud03:password@ud03.kinoko.name/%D6%D0%CE%C4/%D6%D0%CE%C4.rar
?>
function parseurl($url="",$input_charset,$output_charset)
{
$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('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]");
$url = str_replace($entities, $replacements, $url);
return $url;
}
來源:http://tuzwu.iteye.com/blog/648214
沒有留言:
張貼留言