Iconv encoding conversion in php solves Chinese garbled characters. Use the iconv function to convert the captured UTF-8 encoded page to gb2312, it is found that only the iconv function can be used to convert the captured data to code data without any reason. some code is as follows: The iconv function is used to convert the captured UTF-8 encoded page to gb2312, it is found that only the iconv function can be used to convert the captured data into less data for no reason.
| The code is as follows: |
|
Echo $ str = 'Hi, it's coffee sale! '; Echo' '; Echo iconv ('gb2312', 'utf-8', $ str); // Encode the string from GB2312 to UTF-8 Echo' '; Echo iconv_substr ($ str, 1, 1, 'utf-8'); // truncate by number of characters rather than bytes Print_r (iconv_get_encoding (); // Obtain the encoding information of the current page. Echo iconv_strlen ($ str, 'utf-8'); // you can specify the length of the encoded string. // This is also applicable. $ Content = iconv ("UTF-8", "gbk // transcoder", $ content ); ?> |
Iconv ("UTF-8", "GB2312 // IGNORE", $ data)
Ignore indicates that the conversion error is ignored. without the ignore parameter, all strings after this character cannot be saved.
This iconv () function is built in php5.
Then, I found that only the iconv function can be used to convert the captured data into code, and the following code is missing for no reason...