Project

General

Profile

Bug #2627

MySQL UTF8 problem

Added by Boris Nagaev over 8 years ago. Updated over 8 years ago.

Status:
Feedback
Priority:
Normal
Assignee:
Target version:
-
Start date:
01/31/2014
Due date:
% Done:

0%

Estimated time:

Description

Hello!

Consider Wt::Dbo model with WString field.

Using MySQL backend, UTF8 chars (e.g., Russian) are written in wrong way to database. Tables were created by Wt itself.

see http://stackoverflow.com/questions/1008287/illegal-mix-of-collations-mysql-error

it looks like adding "SET collation_connection = 'utf8_general_ci'" would solve this problem.

This bug was found by Ramil Mintaev.

#1

Updated by Wim Dumon over 8 years ago

Hi,

I added a UTF-8 test case.

I couldn't reproduce your error on my own computer. On a different computer, the test failed because the charset of the database was latin1 which could not store one of the test unicode characters. That database was configured with a latin1 charset, which indeed cannot store that character and replaced it by a question mark.

Wt does a "SET NAMES 'utf8';", which should be correct according my understanding of the MySQL manual.

mysql> use mydatabase;
...
mysql> show variables like "character_set_database";
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| character_set_database | utf8  |
+------------------------+-------+
1 row in set (0.01 sec)

mysql> show variables like "collation_database";
+--------------------+-----------------+
| Variable_name      | Value           |
+--------------------+-----------------+
| collation_database | utf8_general_ci |
+--------------------+-----------------+
1 row in set (0.01 sec)

You can further look at the table's charset with the command show full columns from table_a;

I fixed the database with:

alter database wt_test_db character set utf8 collate utf8_general_ci;

and now the tests succeed.

BR,

Wim.

#2

Updated by Wim Dumon over 8 years ago

  • Status changed from New to Feedback
#3

Updated by Koen Deforche over 8 years ago

  • Assignee set to Wim Dumon

Also available in: Atom PDF