MSSQL+unicode

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Brother
Forum Newbie
Posts: 3
Joined: Thu Jan 16, 2003 4:36 am
Contact:

MSSQL+unicode

Post by Brother »

Hello,

I've spent long hours trying to solve this, digged up all the net to no avail.
Here's the setup:
I am using MSDE 2000a version for the database. It's basically MSSQL server 2000, but bared to the db engine only. The testing is done on WinXP PC. PHP version 4.3.9.

I have made one database with one table with one field of nvarchar type. My goals are as follow:
1) Be able to properly read the unicode text string from the database, and be able to display if using PHP, outputting the web page with utf-8 encoding.
2) Be able to write any unicode string (say, I' d have utf-8 encoded string in my hands) to the database.

I am still struggling with the first one. The problem appears to be in the fact, that the character data are being converted using certain encoding, and when they get to the PHP, they are available in that encoding. To my tests, this encoding is derived from the database field collation setting. Unfortunately that means, that while I can easily store characters from multiple charsets in the field (using Enterprise Manager, table open), my opportunitie to read the whole data are limited by the collation setting of this field.
I don't have idea how those other (who are able to read/write unicode data)client tools connect to the MSSQL server, but that just proves that there is a way. It may seem appropriate to expect some kind of method that would allow to set the encoding for PHP-SQLserver communication. That would allow to read/write queries with unicode characters, and that would solve most of the problems. Unfortunately, I couldn't find one.

The next thing I will have to face is, when everything will be looking smooth on my WinXP box, I will have to put the stuff on the online site, which is hosted on Linux server. And that another issues may arise. But let's solve problems one-by-one.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

i don't know much about it, but i expect the first thing you need to do is kick-in the [php_man]mb_string[/php_man] extension?
Brother
Forum Newbie
Posts: 3
Joined: Thu Jan 16, 2003 4:36 am
Contact:

Post by Brother »

timvw wrote:i don't know much about it, but i expect the first thing you need to do is kick-in the [php_man]mb_string[/php_man] extension?
No, not really, it has little to do with this extension, the problem is in the connection between PHP and database server.
Post Reply