Hao
Hao

Reputation: 8115

How to display unicode in MySQL result?

http://www.sqlfiddle.com/#!2/82f65/1

I tried this:

create table x(y varchar(100) character set utf8);

insert into x(y) values('爱');

But the chinese character doesn't appear:

select y from x;

Output:

Y
?

Upvotes: 1

Views: 4646

Answers (3)

Jake Feasel
Jake Feasel

Reputation: 16955

I'm the author of sqlfiddle.com. The problem was that I didn't have my connection string and default database encoding for mysql setup to properly handle UTF8. I have fixed this now, but because the fiddle you posted is still using the obsolete settings, you'll have to see it working here on my slightly-modified version of your fiddle:

http://www.sqlfiddle.com/#!2/e79e8/1

Your link might start working eventually, it just needs to clear out of the running memory and be reset. After no one hits it for a while it should be harvested and then ready to be built back up cleanly. Thanks!

FYI, the changes I had to make to get it to work were found here: http://www.compoundtheory.com/?action=displayPost&ID=421

The relavent bits where adding this to my connection string from java: useUnicode=true&characterEncoding=UTF-8

And adding this to my create database statement:

create database my_new_database default CHARACTER SET = utf8 default COLLATE = utf8_general_ci;

Upvotes: 2

Er. Anurag Jain
Er. Anurag Jain

Reputation: 1793

It is working fine in mysql on my localhost. it may be due to mysql charset or some setting please check it. If you have to run this query via program like php then

run query before select query

"SET NAMES utf8"

It will be return result properly thanks

Upvotes: 2

Shaikh Farooque
Shaikh Farooque

Reputation: 2640

The Chinese character is not displaying in fiddle but in actual mysql database it is working fine. Kindly check your mysql version

Result of your select Statment

Upvotes: 1

Related Questions