Re: Is it possible to save a file with UTF-8 encoding and noBOM using PHP?

From: Date: Sat, 30 Apr 2005 01:27:48 +0000
Subject: Re: Is it possible to save a file with UTF-8 encoding and noBOM using PHP?
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-214253@lists.php.net to get a copy of this message
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

« previous php.general (#214253) next »