Home  >  Article  >  Backend Development  >  怎么把数据从GB2312转换成UTF-8

怎么把数据从GB2312转换成UTF-8

WBOY
WBOYOriginal
2016-06-13 11:54:331384browse

如何把数据从GB2312转换成UTF-8
我使用了iconv和mb_convert_encoding两个函数都试了,然后发现结果是一样的,都会出现各种问题,不是哪里少字了就是直接错误,请问大神怎么解决啊
------解决方案--------------------
gbk 的数据插入到 utf8 的表,只需在插入前执行一次 mysql_query('set names gbk'); 就可以了

mysql_query('set names gbk');
这条指令的作用是:通知 mysql 现在用 gbk 字符集进行操作
转码的工作由 mysql 自己完成

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