在文件中写入特殊字符 [英] Write Special characters in a file

查看:102
本文介绍了在文件中写入特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将数据写入.eps文件,这是我的代码

I am trying to write data in a .eps file, Here is my code

header('Content-Type: text/html; charset=utf-8');'

$var = 'ê';

echo $var;

$file = 'test.eps';

file_put_contents($file, $var);

但是当我打开test.eps时,写入的数据是ê,应该是ê

But when i open test.eps, the data written is ê it should have been ê

请帮助...

推荐答案

我相信您正在处理以下任一问题:

I believe you are dealing with either:

  1. 您创建的源代码文件的字符编码(确保它是UTF-8!)
  2. file_put_contents的默认编码为utf8,因此您应该可以,但您的操作系统或发行版可能会造成干扰.您使用什么操作系统/发行版/版本?

修改 从注释看来,您的文本编辑器似乎有问题.尝试使用适当的编程文本编辑器创建文件的新副本. https://stackoverflow.com/questions/173112/best-lightweight-ide-text-editor

Edit From the comments it sounds like an issue with your text editor. Try creating a new copy of the file using a proper programming text editor. https://stackoverflow.com/questions/173112/best-lightweight-ide-text-editor

这篇关于在文件中写入特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆