這裏是我的代碼:在PHP中,當我使用FWRITE,我沒有得到正確的字符集
<?php
header("Content-Type: text/html; charset=UTF-8");
header("Content-Type: application/x-javascript; charset=UTF-8");
$fName = "demo.txt";
$str = "óé";
fid = fopen($fName, 'wb') or die("can't open file"); // Open file
fwrite($fid, $str); // Write to file
fclose($fid); // Close file
?>
到屏幕上,輸出是:
óéü
當我打開我得到的文件:
óéü
我想使用fwrite保存大量數據,但字符在保存文件時沒有正確編碼。
在此先感謝。
也許試試[這個建議](http://www.php.net/manual/en/function.fwrite.php#73764) – Phil 2011-02-03 06:10:11
對不起,很長的延遲。事實證明,VIEWER是個問題。我有幾個文本編輯器,根據我使用的是哪一個,我會得到UTF-8字符集或NOT!我用Coda完成了一切,並沒有任何其他問題。 – zbinsd 2011-08-10 18:28:18