views:

88

answers:

2

Interesting question... if I have a MySQL table with CHARSET=utf8, and I open a connection with latin1 encoding, what happens?

I tried this, and even characters such as ß and æ could be stored and retrieved properly. Those characters are represented with different byte sequences in utf8 and in latin1, so I didn't expect it to work.

Is MySQL doing some kind of on-the-fly translation between character encodings?

A: 

No, try to dump the database to a file

mysqldump .... > file.sql and compare the encoding of the file

astropanic
+1  A: 

Yes, mysql does make a chrset conversion, depending on configuration. To change the chrset of your connection, you can use SET NAMES like

SET NAMES utf8;
soulmerge
It depends on setting the default-character-set variable.When You have Two different encoded databases (different charsets) you will get different fileencodings in the dumps
astropanic