Home  >  Article  >  Backend Development  >  在PHP中进行GB2312与UTF-8的互换

在PHP中进行GB2312与UTF-8的互换

WBOY
WBOYOriginal
2016-06-01 14:28:06759browse
因为证书中有中文,所以需要在php中进行GB2312与UTF-8的互换。
网上搜索一下这方面相关资料,说是需要php_iconv.dll的支持,可是我在PHP5文件夹中根本找不到这个文件,但是奇怪的是在PHP4中有这个,然后我将PHP4中的php_iconv.dll文件,复制到system32下,却提示出现错误,我想应该也不行,毕竟PHP4和PHP5里面的文件应该不兼容。到这里我就想删除了PHP5,装一个PHP4算了,后来发现一段话:iconv and libxml are compiled into php5ts.dll so you don't need the dll's in version 5.所以只要转换如下:
GB2312 -- UTF-8
iconv("GB2312","UTF-8",$text)
UTF-8 -- GB2312
iconv("UTF-8","GB2312",$text)
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