New hand conversion code question: urltest.txt; $ read & nbsp; fopen ($ url, r) & nbsp; or & nbsp; die (opening failed); $ textfread ($ read, 100 ); fclose ($ read); echo & nbsp; iconv (UTF-8, GBK, this is a test ). & lt; br & gt; # new-user transcoding problems
Using urlpolic'test.txt ';
$ Read = fopen ($ url, 'r') or die ('open failed ');
$ Text = fread ($ read, 100 );
Fclose ($ read );
Echo iconv ('utf-8', 'gbk', 'This is a test ').'
'; # This sentence is OK
Echo iconv ('utf-8', 'gbk', $ text ).'
'; # This error message
The first echo is normal, and the second echo always reports the following error:
Notice: iconv (): Detected an illegal character in input string
Test.txt is in UTF-8 format.
Share: More
------ Solution --------------------
Echo iconv ('utf-8', 'gbk // IGNORE ', $ text)
// IGNORE can IGNORE the words it does not know and then go down to report no error, // transcoder is to cut off the words it does not know and the content behind it, and report an error