iconv、mb_convert_encoding字符编码的转换

来源:互联网 发布:linux 目录使用情况 编辑:程序博客网 时间:2024/05/17 21:43

1.string iconv(string $in_chsrset, string $out_charset, string $str)

函数功能:执行字符编码的转换。

in_charset:输入字符。

out_string:输出字符。(在其后加上//IGNORE能避免iconv函数在转换“—”到gb2312时出错的bug,如:iconv("utf-8", "GB2312//IGNORE",$data))

str:需要转换编码的字符。

2.string mb_convert_encoding(string $str,string $to_encoding, [,mixed $from_encoding])

函数功能:执行字符编码的转换。

str:要转换的字符串。

to_encoding:要转换的编码类型。

from_encoding:转换前的编码类型,如果没有指定,将采用内置。

如:$str= mb_convert_encoding($str,"UTF-7", "EUC-JP");

3. array mb_list_encodings(void)

函数功能:返回所有支持的编码类型。