简体   繁体   中英

SQL server uft8 connection

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 (so NVARCHAR etc). These are stored in the UCS-2 format. The Windows SQLSRV driver will convert those columns from UCS-2 to UTF-8 when retrieving, and the opposite when saving.

However, if the data is ISO-8859-1 (non- N columns) then you will need to convert the text yourself. I would suggest creating a wrapper function on your data retrieval methods to convert ISO-8859-1 data to UTF-8.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM