- $ Content = iconv ("gbk", "UTF-8", $ content); // The first method is easy to use.
- $ Content = mb_convert_encoding ($ content, "UTF-8", "gbk"); // avoid exceptions
// It is found that iconv will encounter an error when converting characters "-" to gb2312. if the ignore parameter is not available, all strings after this character cannot be saved. In any case, the "-" cannot be converted successfully or output. In addition, mb_convert_encoding does not have this bug.
Generally, iconv is used. the mb_convert_encoding function is used to convert UTF-8 encoding to gbk only when the encoding of the original encoding cannot be determined or The iconv conversion fails to be displayed normally.
- $ Content = iconv ("UTF-8", "gbk", $ content); // The first method is easy to use.
- $ Content = mb_convert_encoding ($ content, "gbk", "UTF-8"); // avoid exceptions
For the format, see string iconv (string $ in_charset, string $ out_charset, string $ str) string mb_convert_encoding (string $ str, string $ to_encoding [, mixed $ from_encoding]). |