Inserting Unicode characters with PHP -> ODBC -> MS SQL?

落爺英雄遲暮 提交于 2019-12-01 18:49:55

The problem was not ODBC, but PHP... solution was to use utf8_decode() on the strings returned from the database.

If you are on Windows and running PHP 5.3, using PDO_ODBC with SQL Native Client, and your input text is UTF-8, this should just work automatically.

I would tread carefully here. In the past, when dealing with SQL Server and PHP integration, I have encountered cases where SQL Server uses between 3 and 5 times as much storage space as is actually needed for Unicode characters. Depending on how you connect to the database and how the data is encoded. My understanding is that MSFT is working on a new driver (or it has possibly been out for a while) that addresses the issue and generally improves PHP integration. With some of the older stacks, you might run into trouble. I recommend looking at the data size in the DB to verify that the connection is not padding your data.

Jacob

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!