Re: Is it possible to save a file with UTF-8 encoding and noBOM using PHP?
| From: | Jon Hill | Date: | Thu, 28 Apr 2005 13:19:04 +0000 |
| Subject: | Re: Is it possible to save a file with UTF-8 encoding and noBOM using PHP? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-214087@lists.php.net to get a copy of this message | ||
> 1. First I want to know how to make the actual binary file that is written,
> to be encoded as UTF-8. This is my PRIMARY question.
I think this part is the key. If the string originated from your text editor,
then your text editor needs to be in UTF-8 mode. If you are importing the
data from a file or database then you need to be sure that the data is UTF-8
encoded. If you know that the encoding is instead ISO-8859-1 then you can
convert it to UTF-8 with the php function utf_encode. fwrite will then write
out the bytes that you presented to it. I guess the same applies in reverse
when you read the file back in to the application that will view the text.