dav
dav

Reputation: 9267

mysql shows chinese characters like squares

I want to save chinese characters in mysql db, charset is set to UTF8 via connecting to db, also the field's charset is utf8, and collation - utf8_general_ci,

But instead of the word it shows squares. I use sqlyog.

There is one thing, if I make request and echo the word in the browser if shows the right chinese word.

So, I am wondering why it shows the correct word in browser, when in db it is like squares and vice versa. I am afraid that maybe via exporting or importing in the future I can have some data lose.

Thanks

Upvotes: 1

Views: 426

Answers (2)

twitch
twitch

Reputation: 225

I had a similar problem when I had to insert Latin characters to the database, I used mb_convert_encoding($str, 'utf8', 'HTML-ENTITIES') and it got stored correctly in the database and wen I had to show it in the html page I just had the encoding=utf-8

Upvotes: 0

Tudor Constantin
Tudor Constantin

Reputation: 26861

Your data might be stored correctly in the DB, but read wrongly by sqlyog.

I haven't used sqlyog, but this problem might be because of the way sqlyog connects to MySQL - look for parameters in sqlyog connection to DB that are related to character set and make sure they are also utf8

Upvotes: 1

Related Questions