【发布时间】:2011-02-03 06:06:51
【问题描述】:
这是我的代码:
<?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 保存大量数据,但在文件保存时字符编码不正确。
提前致谢。
【问题讨论】:
-
也许可以试试this suggestion
-
抱歉耽搁了这么久。事实证明,查看器是问题所在。我有几个文本编辑器,并且,根据我使用的哪个,我会得到 UTF-8 字符集还是没有!我最终将 Coda 用于所有事情,并且没有遇到任何其他问题。