dongwei1895 2011-02-03 06:06
浏览 48

在PHP中,当我使用fwrite时,我没有得到正确的字符集

Here is my code:

<?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
?>

To the screen, the output is:

óéü

When I open the file I get:

óéü

I am trying to save large amounts of data using fwrite, but the characters are not encoding correctly at the point of file save.

Thanks in advance.

  • 写回答

3条回答 默认 最新

  • douzheyo2617 2011-02-03 06:11
    关注

    what program are you using to "open" the file? that program could be the problem.

    评论

报告相同问题?

悬赏问题

  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源