Unicode internationalization problem with e-commerce site
| From: | Mattias Håkansson | Date: | Thu, 21 Oct 2004 10:59:56 +0000 |
| Subject: | Unicode internationalization problem with e-commerce site | ||
| Groups: | php.i18n | ||
| Request: | Send a blank email to php-i18n+get-770@lists.php.net to get a copy of this message | ||
Hello,
I am experiencing some problems with internationalization and I can't figure out if
there's a global solution to this issue or if independent application tweaking is needed. These
are my examples
Server config:
Linux dev 2.4.21-20.ELsmp, Red Hat Enterprise Linux ES release 3 (Taroon Update 3)
PHP Version 4.3.2
MySQL Server 4.0.20
Apache 2.0.46
Example 1: selecting unicode chars from mysql client
mysql> select * from test;
+--------+------+
| testID | name |
+--------+------+
| 1 | ÅÄÖ | (a with a dot, a with two dots and o with two dots if this should not be
diplayed properly)
+--------+------+
1 row in set (0.00 sec)
Then i tried to get it out from php
$query = "SELECT * FROM test";
$dbHost = new SQL();
$dbHost->query($query);
$num = $dbHost->getNumRows();
for($i = 0;$i <= $num; $i++)
{
$row = $dbHost->getRow($i);
echo $row->name ."<br>";
}
The browser displays ??? instead.
Example 2: fetching unicode data from the database and writing it to a file on the disk.
select cCityname from blabla where cCode = 'PYASU';
+-----------+
| cCityname |
+-----------+
| Asunción |
+-----------+
1 row in set (0.02 sec)
Notice the forward tick on the o
Then I change the query in example 1 to select this cCityname and I get shown Asunci?n
So instead of displaying it in the browser I instead write the variable to a file, using fopen() and
fwrite().
And when i look at the file it has Asunción in it So that seems to work.
I've been playing around with these two switches in httpd.conf but it doesn't seem to
change anything:
AddDefaultCharset off
AddDefaultCharset UTF-8
Anyone had some similar problems and know what can fix this?
Thanks,
Mattias