Share via


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

Comments

  • Anonymous
    August 29, 2008
    PingBack from http://hoursfunnywallpaper.cn/?p=3830

  • Anonymous
    September 18, 2008
    The comment has been removed

  • Anonymous
    September 18, 2008
    In the driver documentation, all the sample I see for UTF-8 support uses parameters. Is is possible to run a query that has hardcoded where clause? ex: $tsql = "SELECT * FROM MyTable WHERE name LIKE '%é%'" $stmt = sqlsrv_query($conn, $tsql); Thanks