Re: Displaying UTF-8-encoded strings from MySQL with PHP [message #174519 is a reply to message #174517] |
Wed, 15 June 2011 13:23 |
Luke
Messages: 10 Registered: June 2011
Karma:
|
Junior Member |
|
|
On Jun 15, 3:05 pm, Luke <kickingje...@gmail.com> wrote:
> On Jun 15, 2:56 pm, Luke <kickingje...@gmail.com> wrote:
>
>
>
>
>
>>> Whatever, are you sure that your data is actually stored as valid UTF-8
>>> after the migration?
>
>>> The HEX() function can be handy:
>
>>> http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function....
>
>> Hm.. getting closer. But this is very weird:
>
>> // Simply performs a query and returns mysql_fetch_assoc on the first
>> result
>> $hex = $theDB->getResult("SELECT HEX(link_text) FROM language WHERE
>> id=2");
>
>> // Echos "C3BC" (which is the correct value for the character in the
>> DB ("ü"))
>> echo $hex['HEX(link_text)'];
>
>> // Selecting the actual value instead of its hex-represenation
>> $char = $theDB->getResult("SELECT link_text FROM language WHERE
>> id=2");
>
>> // Echos "fc" (which is " " (broken character))
>> echo bin2hex($char['link_text']);
>
>> I'm a little confused. I tried various functions on this:
>
>> $theDB->query("SET NAMES ‘utf8′");
>> mysql_set_charset('utf8');
>> mb_internal_encoding("UTF-8");
>
>> mb_internal_encoding("UTF-8");
>
>> Nothing helps. Changing configurations is not impossible, but very
>> difficult. Also the database seems fine, as HEX(xx) returns the
>> correct value, and in my PHP-Scripts I can use UTF-8 characters (that
>> aren't loaded from the database) and they work too. There must be
>> something in 'between'…
>
> And it seems FC is the "Hex code point" of the character I'm looking
> for. But I actually have no clue what to do. Wikipedia says Hex code
> point marks the range in which characters are assigned to languages
> (more or less), but i'm not sure why that is returned or even how to
> handle this.
Oh wait FC is the ASCII-Value for ü. So the question is, why does PHP
recieve an ASCII-char if the MySQL-Function HEX() returns the correct
UTF-8 hexvalue?
|
|
|