Bug #21673 Typing ALT+0x200 (capital C with caron) inserts wrong code into database
Submitted: 16 Aug 2006 11:45 Modified: 8 Sep 2006 5:48
Reporter: Tonci Grgin Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Charsets Severity:S3 (Non-critical)
Version:4.1, 5.0, 5.1 BK OS:-
Assigned to: Alexander Barkov CPU Architecture:Any

[16 Aug 2006 11:45] Tonci Grgin
Description:
Inserting capital C with caron (cp1250 code 0x200) results in inserting cp852 (AC) code into UTF8 table.

How to repeat:
Start server with default-character-set=utf8

mysql> create database issues default character set=utf8;
Query OK, 1 row affected (0.05 sec)

mysql> use issues;
Database changed
mysql> set names cp1250;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE `t` (
    -> `a` varchar(40) default NULL
    -> ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.01 sec)

mysql> show variables like "%char%";
+--------------------------+-----------------------------------------------------------+
| Variable_name            | Value
       |
+--------------------------+-----------------------------------------------------------+
| character_set_client     | cp1250
       |
| character_set_connection | cp1250
       |
| character_set_database   | utf8
       |
| character_set_results    | cp1250
       |
| character_set_server     | utf8
       |
| character_set_system     | utf8
       |
| character_sets_dir       | /home/Tonci/bkwork/copyto/mysql-4-1/share/mysql/charsets/ |
+--------------------------+-----------------------------------------------------------+
7 rows in set (0.00 sec)

mysql> insert into t values ("Č"); #ALTx0200, my windows console is being polite
Query OK, 1 row affected (0.00 sec)

mysql> select * from t;
+------+
| a    |
+------+
| Č    |
+------+
1 row in set (0.02 sec)

mysql> select HEX(a) from t;
+--------+
| HEX(a) |
+--------+
| C2AC   |
+--------+
1 row in set (0.00 sec)
# Wrong UTF8 value for capital C with caron.

mysql> INSERT INTO t VALUES (_cp1250 0xC8);
Query OK, 1 row affected (0.00 sec)

mysql> select * from t;
+------+
| a    |
+------+
| Č    |
| ╚    |
+------+
2 rows in set (0.00 sec)

mysql> SELECT HEX(a) from t;
+--------+
| HEX(a) |
+--------+
| C2AC   |
| C48C   |
+--------+
2 rows in set (0.00 sec)
The later is correct UTF8 value for capital C with caron.

Suggested fix:
?
[8 Sep 2006 5:48] Alexander Barkov
This is not a bug, this is a client misconfiguration.

"mysqld.exe" is a DOS-alike console application which uses cp852,
not cp1250.

You need to do "SET NAMES cp862" in the beginning of SQL session,
or you can put this line into my.ini, not to type "SET NAMES"
every time:

[mysql]
default-character-set=cp862