Home >Backend Development >PHP Tutorial >Use iconv encoding conversion in PHP to solve the problem of Chinese garbled characters_PHP tutorial
Using the iconv function to convert the captured utf-8 encoded page into gb2312, I found that only by using the iconv function to transcode the captured data, the data will be less for no reason
The code is as follows
|
Copy code
|
||||
echo $str= 'Hello, we sell coffee here!';
echo ' '; |
echo iconv_substr($str, 1, 1, 'UTF-8'); //Truncate by the number of characters instead of bytes
Ignore means to ignore errors during conversion. Without the ignore parameter, all strings following this character cannot be saved. The iconv() function is built-in in php5. http://www.bkjia.com/PHPjc/632242.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632242.htmlTechArticleUse the iconv function to convert the captured utf-8 encoded page into gb2312. I found that only using iconv Once the function transcodes the captured data, the code will be reduced for no reason as follows...