用iconv函数将gb2312转换为utf-8时,怎么有些汉字会出现问题,像"??;字就会提示如下:Notice: iconv() [function.iconv]: Detected an illegal character in input string
解决方法:
- iconv('UTF-8', 'GB2312//IGNORE', '??')
- iconv('UTF-8', 'GBK', '??')
或者是编码不对,或者增加抑制符@,我们还可以使用其它方法操作,做一个GBK To UTF-8
mb_convert_encoding()使用详解,php代码如下:
- header("content-Type: text/html; charset=Utf-8");
- echo mb_convert_encoding("???S我的友仔", "UTF-8", "GBK");
- ?>
再来个GB2312 To Big5,代码如下:
- header("content-Type: text/html; charset=big5");
- echo mb_convert_encoding("你是我的朋友", "big5", "GB2312");
- ?>
|