因为需要不得不将所有网页编码设为 UTF-8(通过<META>声明charset=utf-8),保存也用UTF-8格式。
于是在使用fopen()打开TXT文件的时候出现乱码了。在网上查了一下,转换编码有两种方式:
1、iconv()
2、mb_convert_encodeing()但是我看到使用ICONV()函数之前需要安装什么“函数库”(http://www.jb51.net/article/14530.htm),但是我没有安装,也可以顺利使用。
查了下php手册,它是这样说的。
You will need nothing if the system you are using is one of the recent POSIX-compliant systems because standard C libraries that are supplied in them must provide iconv facility. Otherwise, you have to get the » libiconv library installed in your system.
(翻译得不好= = :如果你在用POSIX-compliant系统的话你不需要其它东西,因为系统的标准C库已经支持iconv函数所需的环境。否则,你需要安装libiconv库到你的系统。)看得半懂。
iconv()函数到底是不是PHP内置的啊?会不会我写的脚本传到其它服务器就有运行不了的可能?
于是在使用fopen()打开TXT文件的时候出现乱码了。在网上查了一下,转换编码有两种方式:
1、iconv()
2、mb_convert_encodeing()但是我看到使用ICONV()函数之前需要安装什么“函数库”(http://www.jb51.net/article/14530.htm),但是我没有安装,也可以顺利使用。
查了下php手册,它是这样说的。
You will need nothing if the system you are using is one of the recent POSIX-compliant systems because standard C libraries that are supplied in them must provide iconv facility. Otherwise, you have to get the » libiconv library installed in your system.
(翻译得不好= = :如果你在用POSIX-compliant系统的话你不需要其它东西,因为系统的标准C库已经支持iconv函数所需的环境。否则,你需要安装libiconv库到你的系统。)看得半懂。
iconv()函数到底是不是PHP内置的啊?会不会我写的脚本传到其它服务器就有运行不了的可能?
+如果你怕有意外情况,那就在网上去下一个: * 中文编码集合类库
*
* 目前该类库可以实现,简体中文 <-> 繁体中文编码互换,简体中文、繁体中文 -> 拼音单向转换,
* 简体中文、繁体中文 <-> UTF8 编码转换,简体中文、繁体中文 -> Unicode单向转换那个比较原始,不需要系统iconv函数的支持。