Write Special characters in a file

Deadly 提交于 2019-12-11 03:20:02

问题


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);

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

Please Help ...


回答1:


I believe you are dealing with either:

  1. The character encoding of the source code file you have created (make sure it is UTF-8!)
  2. The default encoding for file_put_contents is utf8, so you should be okay there but your OS or distro might be interfering. What OS / distro / version are you using?

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



来源:https://stackoverflow.com/questions/9602573/write-special-characters-in-a-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!