Character Set issue using SQL Server and ODBC in php
Asked Answered
N

4

0

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')

Namedropping answered 29/5, 2013 at 11:42 Comment(5)
how to retrieve data? put sample code pleasePitzer
have you checked if you had a BOM issue? I always check that too.Sport
@Fred please explain more.Namedropping
what is your sql statement i mean.also see https://mcmap.net/q/1633977/-php-odbc-encoding-problem and #1231471Pitzer
@Namedropping Consult this link for details en.wikipedia.org/wiki/Byte_order_markSport
N
1

i found the problem.

iconv("Windows-1256", "UTF-8", "$temp")
Namedropping answered 30/5, 2013 at 15:30 Comment(0)
Z
0

Try to use utf8_decode() or utf8_encode().

Zeena answered 29/5, 2013 at 11:52 Comment(0)
P
0

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.

Pitzer answered 29/5, 2013 at 12:0 Comment(0)
D
0

You can change the locale with:

Control Panel -> Region -> Administrative -> Change system locate
Donetta answered 12/9, 2023 at 8:53 Comment(2)
Help them, help me or help you? A little nitpicking, sorry. I ask because I try to determine whether you are trying to answer or saying thanks.Insufferable
I assumed this is a proposed answer. Please double check that the edit is correct.Attested

© 2022 - 2024 — McMap. All rights reserved.