Unicode Support and Endianness

We’ve seen more activity on our MSDN Forum over the past couple weeks (yay!) and there have been a few threads about how/if the SQL Server Driver for PHP supports Unicode. Rest assured, the SQL Server Driver for PHP does support Unicode. The driver expects Unicode strings to be in little endian format, since that's what SQL Server uses.

 

When you convert strings between different encodings in PHP using iconv or mb_convert_encoding, PHP will assume big endian format if you do not specify endianness. In other words, you must specify "ucs-2le" instead of just "ucs-2". The example in our documentation for working with UTF-8 strings did not specify endianness so the strings were converted to and from Unicode in big endian format. We're in the process of correcting that error and apologize for the confusion.

 

For more information on endianness and the origin of the term "endian", see Michael Kaplan's blog post or the Wikipedia entry on endianness.

 

David Sceppa

Program Manager - Microsoft SQL Server Driver for PHP