Re: [PHP] Is it possible to save a file with UTF-8 encoding and no BOM using PHP?
On Fri, April 22, 2005 9:54 pm, Rasmus Lerdorf said: Maybe I'm just being dumb, but I think if you UTF-8 encode your data, and http://php.net/fwrite it, you're gonna get what you want... Dunno about the Byte-Order-Mark part, but I guess you could strip it out of the UTF-8 encoded data before writing, if you wanted to. That was the first thing I tried, and it doesn't seem to work (it always saves in windows default encoding). Unless I missing something about what you can do with fwrite. Did you actually test that before you replied, and found that it would? If so, how? The Byte Order Mark is a part of the binary file that is written, how would one go about stripping it out?? I didn't try anything. I wouldn't know a UTF-8 it it walked up and bit me on the ass. :-) But I *do* know that PHP's fwrite is much too low-level to be doing encoding types and whatnot. It just writes whatever you tell it. If you think it's always saving in windows default encoding, perhaps your test is not distinguishing between having no BOM (whatever that is) and having the Windows BOM or whatever makes you think it's Windows format. As far as getting rid of the BOM, assuming you've got your UTF-8 string thingie, and you know where the BOM occurs, you'd just use http://php.net/substr on it, I reckon... -- 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
Re: [PHP] Is it possible to save a file with UTF-8 encoding and no BOM using PHP?
On Thu, April 21, 2005 5:07 pm, Jon M. said: I am trying to have a file that I generated with PHP saved as UTF-8 without the BOM (Byte Order Mark). Does PHP do anything like this? I am a beginner with PHP, but very technically experienced otherwise. I'm talking about the FILE encoding here -just to be clear. e.g. fopen(what_ever_file, a+) now I want PHP save the file itself with UTF-8, NOT system default. I have searched for hours to find an answer, but have not found any info on the subject. Does PHP have any ability to create a text file saved in UTF-8 encoding??? Maybe I'm just being dumb, but I think if you UTF-8 encode your data, and http://php.net/fwrite it, you're gonna get what you want... Dunno about the Byte-Order-Mark part, but I guess you could strip it out of the UTF-8 encoded data before writing, if you wanted to. -- 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
Re: [PHP] Is it possible to save a file with UTF-8 encoding and no BOM using PHP?
Richard Lynch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Thu, April 21, 2005 5:07 pm, Jon M. said: I am trying to have a file that I generated with PHP saved as UTF-8 without the BOM (Byte Order Mark). Does PHP do anything like this? I am a beginner with PHP, but very technically experienced otherwise. I'm talking about the FILE encoding here -just to be clear. e.g. fopen(what_ever_file, a+) now I want PHP save the file itself with UTF-8, NOT system default. I have searched for hours to find an answer, but have not found any info on the subject. Does PHP have any ability to create a text file saved in UTF-8 encoding??? Maybe I'm just being dumb, but I think if you UTF-8 encode your data, and http://php.net/fwrite it, you're gonna get what you want... Dunno about the Byte-Order-Mark part, but I guess you could strip it out of the UTF-8 encoded data before writing, if you wanted to. -- Like Music? http://l-i-e.com/artists.htm That was the first thing I tried, and it doesn't seem to work (it always saves in windows default encoding). Unless I missing something about what you can do with fwrite. Did you actually test that before you replied, and found that it would? If so, how? The Byte Order Mark is a part of the binary file that is written, how would one go about stripping it out?? BTW, note to PHP developers: If fwrite had a encoding parameter, e.g. UTF-8, that would be REALLY handy. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is it possible to save a file with UTF-8 encoding and no BOM using PHP?
Jon M. wrote: Richard Lynch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Thu, April 21, 2005 5:07 pm, Jon M. said: I am trying to have a file that I generated with PHP saved as UTF-8 without the BOM (Byte Order Mark). Does PHP do anything like this? I am a beginner with PHP, but very technically experienced otherwise. I'm talking about the FILE encoding here -just to be clear. e.g. fopen(what_ever_file, a+) now I want PHP save the file itself with UTF-8, NOT system default. I have searched for hours to find an answer, but have not found any info on the subject. Does PHP have any ability to create a text file saved in UTF-8 encoding??? Maybe I'm just being dumb, but I think if you UTF-8 encode your data, and http://php.net/fwrite it, you're gonna get what you want... Dunno about the Byte-Order-Mark part, but I guess you could strip it out of the UTF-8 encoded data before writing, if you wanted to. -- Like Music? http://l-i-e.com/artists.htm That was the first thing I tried, and it doesn't seem to work (it always saves in windows default encoding). Unless I missing something about what you can do with fwrite. Did you actually test that before you replied, and found that it would? If so, how? The Byte Order Mark is a part of the binary file that is written, how would one go about stripping it out?? BTW, note to PHP developers: If fwrite had a encoding parameter, e.g. UTF-8, that would be REALLY handy. Strings in PHP are binary-safe and character-encoding neutral. fwrite doesn't have a clue what it is writing, it just writes what is in memory. I'd question why you would want to strip the BOM. Any modern system deals with the byte-order-mark correctly. But you can simply strip it manually if it is present in the first 2 bytes before your fwrite if you really need to get rid of it. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Is it possible to save a file with UTF-8 encoding and no BOM using PHP?
I am trying to have a file that I generated with PHP saved as UTF-8 without the BOM (Byte Order Mark). Does PHP do anything like this? I am a beginner with PHP, but very technically experienced otherwise. I'm talking about the FILE encoding here -just to be clear. e.g. fopen(what_ever_file, a+) now I want PHP save the file itself with UTF-8, NOT system default. I have searched for hours to find an answer, but have not found any info on the subject. Does PHP have any ability to create a text file saved in UTF-8 encoding??? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php