php 文字代码,php汉字编码转换的方法
一、iconv
string iconv (
php汉字编码转换的方法:1、使用“string iconv()”方法进行转换;2、通过“mb_convert_encoding”方法进行转换;3、使用“mb_detect_encoding”方法进行转换。 一、iconv string iconv ( string $in_charset , string $out_charset , string $str ) 第一个参数:内容原的编码 第二个参数:目标编码 第三个参数:要转的字符串$filename='我爱你中国';$filename = iconv('gbk','utf-8',$filename);解析:把$filename从gbk转换为utf8 二、mb_convert_encoding string mb_convert_encoding ( string $str , string $to_encoding [, mixed $from_encoding ] ) 第一个参数:要处理的字符串 第二个参数:目标编码 第三个参数:内容原编码$filename='我爱你中国';$filename = mb_convert_encoding($filename,'GBK','UTF-8');解析:把$filename从utf8转换为gbk 三、mb_detect_encoding查看字符编码$filename='我爱你中国';$encode = mb_detect_encoding($filename, array("ASCII","UTF-8"php编码,"GB2312","GBK","BIG5"));echo $encode;die; (编辑:晋中站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |