Project

General

Profile

Actions

Bug #2627

open

MySQL UTF8 problem

Added by Boris Nagaev almost 11 years ago. Updated almost 11 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.

Actions #1

Updated by Wim Dumon almost 11 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.

Actions #2

Updated by Wim Dumon almost 11 years ago

  • Status changed from New to Feedback
Actions #3

Updated by Koen Deforche almost 11 years ago

  • Assignee set to Wim Dumon
Actions

Also available in: Atom PDF