PHP + SQL Server - How to set charset for connection?

前端 未结 13 1192
借酒劲吻你
借酒劲吻你 2020-12-01 06:54

I\'m trying to store some data in a SQL Server database through php.

Problem is that special chars aren\'t converted properly. My app\'s charset is iso-8859-1 and th

13条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-01 07:08

    I suggest looking at the following points:

    1. Ensure that the columns that you're storing the information in are nchar or nvarchar as char and nvarchar don't support UCS-2 (SQLServer doesn't store in UTF-8 format btw)
    2. If you're connecting with the mssql library/extension for PHP, run: ini_set('mssql.charset', 'utf-8'); as there's no function with a charset argument (connect, query etc)
    3. Ensure that your browsers charset is also set to UTF-8

提交回复
热议问题