Sathesh
Sathesh

Reputation: 41

Encoding gets lost while exporting database

I'm facing a weird issue with file encoding while exporting the database.

To put it simply,

Exporting database DON'T preserve Unicode characters. Exporting individual tables DO preserve Unicode characters.

The dump sql file that I get when I export it as a whole database even has the default charset set to utf8 such as below.

CREATE TABLE content_field_tamil ( vid int(10) unsigned NOT NULL default '0', nid int(10) unsigned NOT NULL default '0', field_tamil_value longtext, field_tamil_format int(10) unsigned default NULL, PRIMARY KEY (vid), KEY nid (nid) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Sample field value of field 'field_tamil_value':

‡Æâ‡Æ±‡Øç‡Æ±‡Ææ‡Æ∞ - This is what I get when I export it as a whole database in .sql file. This is wrongly encoded. உற்றார் - This is what I get when I export individual tables. And this is correct.

I don't understand why it's encoding differently when I export it as a whole database. And, it does the same in my localhost test database. Any help is really appreciated guys.

Upvotes: 1

Views: 391

Answers (1)

user17753
user17753

Reputation: 3161

I'm not sure if you've tried this, but is the charset on the database set to utf8? E.g. not just the tables.

CREATE DATABASE db_name
    [[DEFAULT] CHARACTER SET charset_name]
    [[DEFAULT] COLLATE collation_name]

ALTER DATABASE db_name
    [[DEFAULT] CHARACTER SET charset_name]
    [[DEFAULT] COLLATE collation_name]

Upvotes: 1

Related Questions