SQLServer data in PHP loses multibyte characters

I have PHP talking to SQLServer through ODBC using FreeTDS and unixODBC. I followed tutorials to get this setup. It's working fine now although special characters in the database are not showing up correctly. Specifically, the ™ symbol. It's showing up in the browser as �. I've tried setting client charset = UTF-8 in the [global] section of freetds.conf. I've tried iconv('UCS-2', 'UTF-8', $str) and mb_convert_encoding($str, 'UTF-8', 'UCS-2') within PHP and both result in asian character sets (䐧祲圠攮戮餮吠渭捥❫). I'm stumped! Anyone have any tips?

One other element that bears mentioning: When I run this code on my local machine, I don't have these issues. The ™, for example, shows up fine. My local machine is a mac and I'm using Actual Technologies ODBC driver. Where I'm having trouble is our LAMP webserver. This leads me to believe that problem lies in the driver configuration. Or possibly linux as whole needs to be informed of UTF-8?

14.10.2009 00:41:44
I assume that the columns in your database are NVARCHARs. (Which can hold Unicode, unlike regular VARCHARs)
SLaks 14.10.2009 00:44:57
1 ОТВЕТ

As it shows in the browser with that symbol, have you confirmed that the HTML page has the correct charset?

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

If so, have you confirmed you are using the correct data type for the column?

0
14.10.2009 00:49:11
That is in there. I can echo out a UTF-8 symbol directly and it shows up. It's their database data that is messed up. See here: i38.tinypic.com/2mn3q84.jpg. The TM is echoed out from PHP. The other stuff is what I'm getting from the DB.
weotch 14.10.2009 00:59:50
Okay, the TM is fine, what isn't? Your original message says the TM shows up as the question mark symbol. Can you post the entire text that you want stored now that you've posted an example picture of the output?
mimetnet 14.10.2009 01:21:50
That text should read: ™'Dry W.E.B.™ T-Neck'. In PHP the code that generates that looks like: echo '™'; echo $row['name']; Also, check out the new paragraph I added to the description of the problem.
weotch 14.10.2009 01:50:27