Home >Backend Development >PHP Tutorial >关于txt文件导入数据库编码的有关问题

关于txt文件导入数据库编码的有关问题

WBOY
WBOYOriginal
2016-06-13 10:48:54862browse

关于txt文件导入数据库编码的问题
现在导入txt文件到数据库,因为编码的原因有些数据写入失败

我在前面加入以下代码后,数据都能导进去,不过全是?????号
mysql_query( "set names 'GBK'");

请问怎么把txt文件内容都转成uft-8的编码
我用以下代码好像不起作用
mb_convert_encoding($u[11], 'UTF-8','ascii,GB2312,gbk,UTF-8');

------解决方案--------------------
$txt = mb_check_encoding($s, 'utf-8') ? $txt : mb_convert_encoding($s, 'utf-8', 'gbk');

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