string iconv ( string $in_charset , string $out_charset , string $str )
When using this function to convert string encoding, you need to pay attention. If you convert utf-8 When it is gb2312, the string may be truncated.
You can use the following method to solve this problem:
Copy the code The code is as follows:
//author: zhxia
$str=iconv('utf-8',"gb2312//TRANSLIT",file_get_contents($filepath));
That is, add the red part in the second parameter, which means: if 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.
http://www.bkjia.com/PHPjc/322644.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322644.htmlTechArticlestring iconv ( string $in_charset , string $out_charset , string $str ) Use this function to perform string encoding conversion When converting utf-8 to gb2312, it may be...