I’m using SQL server with an intranet application written in PHP. For convenience i want to use UTF8 charset for web pages (jquery supports only utf8) however all data stored in my sqlserver db is in iso-8859-1.
Can I change just the data CONNECTION CHARSET (not data store charset) between sqlserver and PHP? Maybe just with a query header?
Thank you.
SQL server only stores Unicode data in tables prefixed with
N(soNVARCHARetc). These are stored in the UCS-2 format. The Windows SQLSRV driver will convert those columns fromUCS-2toUTF-8when retrieving, and the opposite when saving.However, if the data is
ISO-8859-1(non-Ncolumns) then you will need to convert the text yourself. I would suggest creating a wrapper function on your data retrieval methods to convertISO-8859-1data to UTF-8.