新手转码有关问题
新手转码问题$urltest.txt$read fopen($url,r) or die(打开失败)$textfread($read,100)fclos
新手转码问题
$url='test.txt';
$read = fopen($url,'r') or die('打开失败');
$text=fread($read,100);
fclose($read);
echo iconv('UTF-8','GBK','这是一个测试').'<br/>';#这句OK
echo iconv('UTF-8','GBK',$text).'<br/>';#这句报错
以上第一个echo正常,第二个echo就老是报以下错误:
Notice: iconv(): Detected an illegal character in input string
test.txt文件为UTF-8格式。
[解决办法]echo iconv('UTF-8','GBK//IGNORE',$text)
//IGNORE能忽略掉它不认识的字接着往下转不报错,//TRANSLIT是截掉它不认识的字及其后面的内容,报错