回覆列表
-
1 # 有點IT
-
2 # 愛上你愛的
$content=file_get_contents(iconv("GBK","utf-8//IGNORE", "800.txt"));
-
3 # 變餅檔
首先要保證整個php檔案是utf-8的格式
//最好寫上去,因為這也可能是頁面沒有設定字符集
echo "<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />";
//獲得字串之後馬上把字串轉成另一種編碼
$content = file_get_contents("800.txt");
$content = mb_convert_encoding($content, "utf-8", "gbk");
建議採用按行讀取的方式,讀取後進行編碼轉換,編碼可能是GBK或GB2312
$filename = "800.txt";$fh = fopen($filename, "r");while (! feof($fh)) { $line = fgets($fh); $line = iconv("GBK","UTF-8",$line); echo $line;}