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

Your name:

Reply:


Posted by Richard Lynch on 04/29/05 03:57

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация