Character Set issue using SQL Server and ODBC in php

馋奶兔 提交于 2019-12-13 04:56:52

问题


I connected to to sqlsever2008 with odbc(with dsn) and php but problem is that when I retrieve information from that it has character like ���������. My datatype in sqlserver is nvarchar. Any idea why it is happening?

NOTE: The page is utf8.

Edit:

I use echo utf8_encode(odbc_result($this->result,'name') ); and characters are like:

ÂãæÒÔ ÒÈÇäÂãæÒ 

i retrieve information like this:

odbc_result($this->result,'name')


回答1:


Try to use utf8_decode() or utf8_encode().




回答2:


It seems, the code page your sql server has been installed is different with your native language. perhaps you need to reinstall the sql server with correct code page.




回答3:


i found the problem.

iconv("Windows-1256", "UTF-8", "$temp")


来源:https://stackoverflow.com/questions/16812943/character-set-issue-using-sql-server-and-odbc-in-php

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