Home > Article > Backend Development > php function iconv interception error solution_PHP tutorial
iconv function : Requirements for converting the character encoding of a string
Syntax: string iconv ( string in_charset, string out_charset, string str)
When using this function When converting string encoding, please note that if you convert utf-8 to gb2312, the string may be truncated.
You can use the following method to solve this problem:
$str=iconv(utf-8,"gb2312//TRANSLIT",file_get_contents($filepath));
That is, when the second parameter appears Add a red part to indicate: If no character matching the source encoding is found in the target encoding, similar characters will be selected for conversion.
You can also use the //IGNORE parameter here to ignore characters that cannot be converted.