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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, April 28, 2005 4:14 am, Jon M. said:
> 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".

How do you know?

What are you using to determine the format of the file?

We are contending that either you are *not* writing UTF-8 data, but are
writing iso-8859-1 data, or the software telling you that it's not UTF-8
is just plain *wrong*

fwrite just takes your data and dumps it on the hard drive.

It doesn't know UTF-8 from U2.

> 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?

You are mis-informed.

> How do you actually control the way the binary file itself is written, and
> not just the text that is saved in the file?

If you are using Windows, then *WINDOWS* is, perhaps, guessing on the
binary format based on the file 'extension' (.txt) and on the contents.

First, try renaming the file to, err, whatever Windows thinks UTF-8 file
extensions should be... ".utf8" ??? Whatever Notepad uses.

Next, forget what Windows desktop tells you.  It's bull.

When you get the data back out of the file, what format is it?

PS You may be confusing Windows by writing UTF-8 without the BOM, and so
Windows then thinksit's iso-8859-1, because it's no longer a valid UTF-8
file!  You can make Windows happy; or you can make W3c happy.  Not both.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux