Bug #6527 corruption of unicode char 0x0401 (utf8 0xd081) when saving it into utf8-table
Submitted: 9 Nov 2004 18:31 Modified: 15 Nov 2004 19:27
Reporter: Alexander Valyalkin Email Updates:
Status: Not a Bug Impact on me:
Category:MySQL Server: MyISAM storage engine Severity:S3 (Non-critical)
Version:4.1.7 OS:Linux (Linux, Windows)
Assigned to: CPU Architecture:Any

[9 Nov 2004 18:31] Alexander Valyalkin
Mysql corrupts unicode char 0x0401 (russian uppercase letter yo).

How to repeat:
See PHP code below, which explains the bug:

    table structure:

    CREATE TABLE utf (
      id int unsigned NOT NULL auto_increment,
      str varchar(10) NOT NULL,
      PRIMARY KEY  (id)

$char = pack('H*', 'd081'); // unicode char 0x0401 in utf8 encoding
// insert it into database
// $dbh - mysqli database handler
$dbh->query("INSERT INTO utf SET str = '${char}'");
// get the id of the inserted char
$id = $dbh->insert_id;
// select it from database
$sth = $dbh->query("SELECT str FROM utf WHERE id = ${id}");
list($char) = $sth->fetch_row();
// unpack the char
$tmp = unpack('H*', $char);
echo $tmp[1]; // !!!ERROR!!! echoes d03f instead of d081

Suggested fix:
I don't know :)
[12 Nov 2004 14:49] MySQL Verification Team
What is the output of SHOW VARIABLES LIKE "character%"?
Check that appropriate variables are set to utf8.
[15 Nov 2004 17:47] Alexander Valyalkin
I've decided my problem by setting the following character_set_* by utf8:
SET character_set_client = utf8;
SET character_set_connection = utf8;
SET character_set_results = utf8;