Japanese text in MSSQL database
am 14.03.2007 19:54:22 von Mike Matz
------_=_NextPart_001_01C7666A.2DE538B2
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hello,
=20
I'm working with an MSSQL 2000 database that contains Japanese
characters in ntext columns. I'm not entirely sure how to see what
encoding or charset it's using, but there is a ColdFusion admin
application that can display the data in UTF8 as well as accept the
data. I'm trying to access this data from PHP for import into a MySQL
database, and I'm currently using the PDO ODBC driver. I had difficulty
getting other drivers working when I began importing data, either due to
the charset/encoding on these fields or due to the long text in some of
the fields, and the PDO ODBC driver in PHP 5.2.0+ was the one that
seemed to work the best. However, I'm just now realizing that the
Japanese characters are being replaced with "?" characters when I do the
select. I found I had this problem on the MySQL end before, but I
solved it by adding some SQL calls when initializing the connection:
=20
"SET CHARACTER SET utf8",
"SET collation_connection =3D 'utf8_general_ci'",
"SET character_set_database =3D utf8",
"SET character_set_server =3D utf8",
"SET character_set_client =3D utf8",
"SET character_set_filesystem =3D utf8",
Is there something similar I need to do with MSSQL? Is there an option
in the PDO ODBC driver I need to set somehow? I'm guessing there's
probably a simple solution but thus far I've been unable to find
anything. Any help or insight would be greatly appreciated!
=20
Thanks,
Mike
------_=_NextPart_001_01C7666A.2DE538B2--
RE: Japanese text in MSSQL database
am 20.03.2007 23:24:50 von Mike Matz
I wanted to follow up on this because I didn't get any responses. I did
eventually get proper Japanese text from the MSSQL database using a COM
object and the MS ADODB tools:
$obj=3Dnew COM('ADODB.connection',NULL,CP_UTF8);
$obj->open("Provider=3Dsqloledb;Data Source=3D$server,1433;Network
Library=3DDBMSSOCN;Initial Catalog=3D$database;User
ID=3D$username;Password=3D$password;")
I set this up in a custom ADODB class and simply used it to re-populate
international fields in the data I was already getting from PDO. It's a
pretty sloppy solution but it was easier to continue using the PDO
interface for the majority of my code.
Hope this helps someone in the future :)
-----Original Message-----
From: Mike Matz [mailto:mmatz@2advanced.com]=20
Sent: Wednesday, March 14, 2007 11:54 AM
To: php-windows@lists.php.net
Subject: [PHP-WIN] Japanese text in MSSQL database
Hello,
=20
I'm working with an MSSQL 2000 database that contains Japanese
characters in ntext columns. I'm not entirely sure how to see what
encoding or charset it's using, but there is a ColdFusion admin
application that can display the data in UTF8 as well as accept the
data. I'm trying to access this data from PHP for import into a MySQL
database, and I'm currently using the PDO ODBC driver. I had difficulty
getting other drivers working when I began importing data, either due to
the charset/encoding on these fields or due to the long text in some of
the fields, and the PDO ODBC driver in PHP 5.2.0+ was the one that
seemed to work the best. However, I'm just now realizing that the
Japanese characters are being replaced with "?" characters when I do the
select. I found I had this problem on the MySQL end before, but I
solved it by adding some SQL calls when initializing the connection:
=20
"SET CHARACTER SET utf8",
"SET collation_connection =3D 'utf8_general_ci'",
"SET character_set_database =3D utf8",
"SET character_set_server =3D utf8",
"SET character_set_client =3D utf8",
"SET character_set_filesystem =3D utf8",
Is there something similar I need to do with MSSQL? Is there an option
in the PDO ODBC driver I need to set somehow? I'm guessing there's
probably a simple solution but thus far I've been unable to find
anything. Any help or insight would be greatly appreciated!
=20
Thanks,
Mike
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php