mymysql icon indicating copy to clipboard operation
mymysql copied to clipboard

Problem with character encoding

Open bessey opened this issue 12 years ago • 3 comments

This is almost certainly me making a stupid mistake but I don't know where else to ask!

I am attempting to insert UTF-8 encoded data into a table. If I insert the data directly using the mysql command prompt, it works fine. If I use mymysql, L’ Échafaud becomes L’ Échafaud.

It was my understanding that mymysql uses UTF-8 by default. Just in case I added the explicit db.Register("set names utf8") but that hasn't helped either.

Is there something else I need to do in Go to insert UTF-8 encoded strings?

bessey avatar Feb 09 '13 02:02 bessey

Dnia 09.02.2013 o 03:39 Matthew Bessey [email protected] Matthew
Bessey [email protected] napisał(a):

This is almost certainly me making a stupid mistake but I don't know
where else to ask!

I am attempting to insert UTF-8 encoded data into a table. If I insert
the data directly using the mysql command prompt, it works fine. If I
use mymysql, L’ Échafaud becomes L’ Échafaud.

It was my understanding that mymysql uses UTF-8 by default. Just in case
I added the explicit db.Register("set names utf8") but that hasn't
helped either.

Is there something else I need to do in Go to insert UTF-8 encoded
strings?


Reply to this email directly or view it on GitHub: https://github.com/ziutek/mymysql/issues/57

You only need to use "set names utf8" command. Try it in mysql.

What encoding is used in table? Is it VARCHAR or TEXT field?

Please don't create issue in tracker if you only want ask question.

Michał Derkacz

ziutek avatar Feb 11 '13 14:02 ziutek

Hey, apologies for asking in the wrong place, would you rather move this discussion elsewhere? My email is [email protected]

bessey avatar Feb 15 '13 12:02 bessey

add this to section [mysqld] in my.cnf

character-set-server=utf8
collation-server=utf8_unicode_ci

ex-troll avatar Feb 16 '13 20:02 ex-troll