Posted by Rasmus Lerdorf on 04/30/05 04:27
Jon M. wrote:
> No matter what I do to the strings to encode them in whatever format before
> using "fwrite", it ALWAYS seems to end up writing the actual file in
> "iso-8859-1".
>
> Isn't the encoding of the characters in PHP's strings, and the encoding of
> the actual binary file on your hard drive, two totally different things? Or
> am I just misinformed?
A file is completely defined by its contents. If you fwrite UTF-8 data
to the file, then it is a UTF-8 file. Whether your editor, or whatever
it is you are using to determine the file is being written as iso-8859-1
is smart enough to pick this up is a completely different question.
Why don't you try creating the same contents with PHP and with your
preferred text editor and then compare the contents. Perhaps your
editor is dropping a hint somewhere in it that you are not writing to
the file from PHP.
-Rasmus
[Back to original message]
|