Bug #11788 | with character_set_* set to utf8 the command line client garbles german umlaute | ||
---|---|---|---|
Submitted: | 6 Jul 2005 22:40 | Modified: | 6 Jul 2005 23:49 |
Reporter: | Jonas Maurus | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Command-line Clients | Severity: | S3 (Non-critical) |
Version: | 4.1.12a | OS: | Windows (Windows XP) |
Assigned to: | CPU Architecture: | Any |
[6 Jul 2005 22:40]
Jonas Maurus
[6 Jul 2005 23:49]
MySQL Verification Team
The issue here is the terminal: c:\mysql\bin>mysql -uroot test Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 to server version: 4.1.12a-nt Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create table messages ( -> id int not null auto_increment primary key, -> messageSubject varchar(255), -> messageText text); Query OK, 0 rows affected (0.05 sec) mysql> mysql> insert into messages values(0, "Umlauttest2", "äöüÜÖÄß éèâ àáô"); Query OK, 1 row affected, 1 warning (0.00 sec) mysql> show warnings; +---------+------+--------------------------------------------------+ | Level | Code | Message | +---------+------+--------------------------------------------------+ | Warning | 1265 | Data truncated for column 'messageText' at row 1 | +---------+------+--------------------------------------------------+ 1 row in set (0.00 sec) mysql> set character set 'utf8'; Query OK, 0 rows affected (0.00 sec) mysql> insert into messages values(0, "Umlauttest2", "äöüÜÖÄß éèâ àáô"); Query OK, 1 row affected, 1 warning (0.00 sec) mysql> select * from messages; +----+----------------+-----------------------------------+ | id | messageSubject | messageText | +----+----------------+-----------------------------------+ | 1 | Umlauttest2 | ÔÇ×ÔÇØ?┼íÔäó┼¢├í ÔÇÜ┼áãÆ ÔǪ┬áÔÇ£ | | 2 | Umlauttest2 | | +----+----------------+-----------------------------------+ 2 rows in set (0.00 sec) mysql> set names cp1251; Query OK, 0 rows affected (0.00 sec) mysql> insert into messages values(0, "Umlauttest2", "äöüÜÖÄß éèâ àáô"); Query OK, 1 row affected (0.00 sec) mysql> select * from messages; +----+----------------+-----------------+ | id | messageSubject | messageText | +----+----------------+-----------------+ | 1 | Umlauttest2 | äö??Ö?? é?? àáô | | 2 | Umlauttest2 | | | 3 | Umlauttest2 | äöüÜÖÄß éèâ àáô | +----+----------------+-----------------+ 3 rows in set (0.00 sec) mysql>
[7 Jul 2005 0:58]
Jonas Maurus
Sorry, I don't get that. My issue is exactly that I expected the mysql command-line client to silently convert the terminal codepage (cp1252) to utf8 if the database is created with a "default character set 'utf8'" clause (as shown in the report). As your table output shows, all characters that were inserted with the server expecting unicode have been garbled, or lost. This means that for multi-language databases any SQL has to include a "set names" - hint to make sure the server expects the character set of the current terminal? or does the server then internally convert the input strings to utf8 and the client effectively looses the data? I didn't try the "set names" directive explicitly, but I tried setting charset_set_client and character_set_connection manually before... I might have misunderstood the relevant documentation, if possible please clarify. Thanks a lot.