![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
相关问题
最好的方法是开启iconv库。
如果主机没有开启iconv库,我们可以用exec调用unix的iconv库。
[php]
<?php
function myiconv($inCharset,$outCharset,$str)
{
$tempfile = "/tmp/".rand(10000,99999);
exec("echo ".$str.">> ".$tempfile);
$str = exec("iconv -f ".$inCharset." -t ".$outCharset." ".$tempfile);
exec("rm -f ".$tempfile);
return $str;
}
//echo myiconv("gb2312","UTF-8","中华人民共和国");
?>
[/php]
如果您不幸使用了windows主机或exec被系统管理屏蔽,那么最要用最后一招,用编码对照的办法逐字转换,速度不是一般地慢~~,这方面的资料很多,放狗搜搜。。。
提问者:chinaboy 08-17 16:04
答复

