Tom Tom - 2 months ago 18
MySQL Question

MySQL insert and unicode characters

Here is sample code:

CREATE DATABASE test_unicode DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;

USE test_unicode;

CREATE TABLE simple_table (text varchar(100) NOT NULL);

INSERT INTO simple_table VALUES ('l\u2019agave');

SELECT * FROM simple_table;


And here is output:

+-------------+
| text |
+-------------+
| lu2019agave |
+-------------+
1 row in set (0.00 sec)


Mysql stored my string without - " \ "

I need to get "l\u2019agave" with - " \ "

How I can do it?

I tried a lot of encoding settings to mysql, but it not working for me...

Thanks for your advices!

Answer

Try

INSERT INTO simple_table VALUES ('l\\u2019agave');
Comments