Home  >  Article  >  Backend Development  >  求 ANSI编码转UTF8编码 实现代码,该怎么处理

求 ANSI编码转UTF8编码 实现代码,该怎么处理

WBOY
WBOYOriginal
2016-06-13 13:27:071261browse

求 ANSI编码转UTF8编码 实现代码
我用php开发的系统大多运行于unix环境下,所有的编码都是utf8的(数据库和网页),但经常读取windows操作系统上传的文件,会出现乱码,原因是windows系统的文件编码都是ansi的。这需要转换。
第一,我不能要求用户去转换。
第二,unix上的php系统很多都不支持mbstring模块。而且有些虚拟空间根本就不允许做任何设置,更不用说添加组件。所以我需要手动编写一个转换函数,以便正确的读取ansi文件。
求代码,谢谢。

------解决方案--------------------
iconv() 不行?
------解决方案--------------------
提供一个上传页面,把内容iconv从GBK转utf8就行了。

数据库现有数据转编码貌似得导出来,然后iconv,再导回去,手动操作一下吧。

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