News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Ahmed Shreef's Blog:
iconv misunderstands UTF-16 strings with no BOM
August 27, 2010 @ 13:36:56

Ahmed Shreef has a recent post to his blog about an issue he had converting UTF-16 strings over to UTF-8 with the iconv functionality in PHP. Specifically, he ended up with "rubbish unreadable characters" after the conversion.

I had a problem last week with converting UTF-16 encoded strings to UTF-8 using PHP's iconv library on a Linux server. my code worked fine on my machine but the same code resulted in a rubbish unreadable characters on our production server.

In his example (a basic "Hello World" in Arabic) he notes that there's no byte order mark on the string and, because of this, the iconv feature tries to guess if it's big-endian or little-endian. This guessing varies from machine to machine resulting in the inconsistencies he saw. The solution is to define the "to" and "from" for the conversion manually rather than letting it just guess.

0 comments voice your opinion now!
byteordermark bom iconv utf16 utf8 convert


blog comments powered by Disqus

Similar Posts

Justin Silverton\'s Blog: Converting PHP Scripts to Windows Apps

Edd Mann: Reversing a Unicode String in PHP using UTF-16BE/LE

Engrowe.com: How-to - Convert a RSS feed to JSON in PHP

Reddit.com: Let's talk Character Encoding

Ahmed Shreef's Blog: iconv misunderstands UTF-16 strings with no BOM


Community Events

Don't see your event here?
Let us know!


library performance series php7 symfony2 api language conference community introduction interview release framework laravel podcast configure example voicesoftheelephpant application opinion

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework