|
<OL><LI><CODE><FONT face=新宋体><?php </FONT></CODE><LI><CODE><FONT face=新宋体>function myiconv($inCharset,$outCharset,$str) </FONT></CODE><LI><CODE><FONT face=新宋体>{ </FONT></CODE><LI><CODE><FONT face=新宋体> $tempfile = "/tmp/".<A href="http://www.php.net/manual/zh/function.rand"><U><FONT color=#0000ff>rand</FONT></U></A>(10000,99999); </FONT></CODE><LI><CODE><FONT face=新宋体> <A href="http://www.php.net/manual/zh/function.exec"><U><FONT color=#0000ff>exec</FONT></U></A>("echo ".$str.">> ".$tempfile); </FONT></CODE><LI><CODE><FONT face=新宋体> $str = <A href="http://www.php.net/manual/zh/function.exec"><U><FONT color=#0000ff>exec</FONT></U></A>("iconv -f ".$inCharset." -t ".$outCharset." ".$tempfile); </FONT></CODE><LI><CODE><FONT face=新宋体> <A href="http://www.php.net/manual/zh/function.exec"><U><FONT color=#0000ff>exec</FONT></U></A>("rm -f ".$tempfile); </FONT></CODE><LI><CODE><FONT face=新宋体> return $str; </FONT></CODE><LI><CODE><FONT face=新宋体>} </FONT></CODE><LI><CODE><FONT face=新宋体>//echo myiconv("gb2312","UTF-8","中华人民共和国"); </FONT></CODE><LI><CODE><FONT face=新宋体>?></FONT></CODE></LI></OL>< RE> 转换文件: exec('iconv -f '.$inCharset.' -t '.$outCharset.' -o '.$file.' '.$file); </PRE> |
|