Iconv is not the default function of PHP, but also the default installed module. Installation is required.
Modify PHP in windows. INI file, remove ";" before extension = php_iconv.dll, and copy the iconv under your original PHP installation file. DLL to your winnt/system32.
In Linux, you can add one more item -- With-iconv to configure by using static installation. phpinfo shows the iconv items.
String iconv (string in_charset, string out_charset, string Str)
Note: In addition to specifying the encoding to be converted, you can also add two suffixes: // Transcoder and // ignore, // Transcoder automatically converts a character that cannot be directly converted into one or more similar characters. // ignore ignores the characters that cannot be converted, by default, the result is truncated from the first invalid character.
String mb_convert_encoding (string STR, string to_encoding [, mixed from_encoding])
Enable mbstring extension Library first, and remove the extension library before extension = php_mbstring.dll in PHP. ini.
Mb_convert_encoding can specify multiple input encodings, which are automatically identified based on the content.
Note that:
1. iconv will encounter an error when converting characters "-" To gb2312. Without the ignore parameter, all strings after this character cannot be saved. mb_convert_encoding does not have this bug.
2. The execution efficiency of mb_convert_encoding is much lower than that of iconv. It is used only when the iconv conversion fails to display normally.