Home >php教程 >php手册 >php中UTF8编码页面iconv转码失败

php中UTF8编码页面iconv转码失败

WBOY
WBOYOriginal
2016-06-13 09:56:501066browse

本文章来介绍UTF8编码页面存入GBK数据时使用iconv遇到无法转码的字符时中断内容丢失及解决方法,有碰到此类问题的同学可参考。

关于iconv遇到无法转码的字符时中断内容丢失

 代码如下 复制代码

$c = ‘测试•字符传换•五一快乐!’;

echo iconv(‘utf-8′, ‘gbk’,$c);

只会输出: 测试

后出全会丢失.

解决方法:

加 //IGNORE

 代码如下 复制代码

$c = ‘测试•字符传换•五一快乐!’;

echo iconv(‘utf-8′, ‘gbk//IGNORE’,$c);

输入出:测试字符传换五一快乐!

ignore的意思是忽略转换时的错误,如果没有ignore参数,所有该字符后面的字符串都无法被保存。
这样就可以进行同

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn