non-unicode character problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
markthien
Forum Commoner
Posts: 33
Joined: Fri Feb 13, 2009 7:50 pm

non-unicode character problem

Post by markthien »

Hi guys,

when user enter non-unicode character like chinese characters and I save it to mysql database which become funny character like 手冢治虫 司徒剑桥 å. However, when retrieving it and it display correctly on webpage. is there anyway I can display it correctly in the database where actual chinese character is showed?

I need this because my java application will grab data from database and send out the message to user via SMS and when I check my SMS in my cell phone, all the chinese character also the same as the database one instead of the correct one.

I tried to manually change the data in the database by directly enter chinese character and when sent out the message and I check my cell phone, all the chinese character display correctly.

In addition to that, if the chinese character in the database is actual one like 周华建是怎样一首歌 instead of 手冢治虫 司徒剑桥 å, the webpage display all the chinese character like ?????????

appreciate anyone could help me on this.

regards,
Mark
Cirdan
Forum Contributor
Posts: 144
Joined: Sat Nov 01, 2008 3:20 pm

Re: non-unicode character problem

Post by Cirdan »

All that means is that whatever you use to view your DB doesn't support unicode. As for your web browser, it is probably because you don't have that language installed.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: non-unicode character problem

Post by requinix »

That mojibake you're seeing is the UTF-8 encoding of those Chinese characters.

If you're looking at the database directly then it means the characters got utf8_encoded before they were inserted. If you're looking at those characters through the browser then your page isn't set to render as UTF-8.

Code: Select all

header("Content-Type: text/html; charset=utf-8");

Code: Select all

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Either of those should work.
markthien
Forum Commoner
Posts: 33
Joined: Fri Feb 13, 2009 7:50 pm

Re: non-unicode character problem

Post by markthien »

you are wrong Cirdan. mysql support utf8 character and I have also set the table/field Charset=utf8 and collation=utf8_general_ci.
if you do not know please do not simple answer question here ok!
markthien
Forum Commoner
Posts: 33
Joined: Fri Feb 13, 2009 7:50 pm

Re: non-unicode character problem

Post by markthien »

hello tasairis,

It still doesn't work. ok there are 2 situation here:

1. when I use sqlyog to view my data, it display the chinese character correctly like 四大名捕漫画. However, it display ?????? on the webpage.

2. when I use sqlyog to view my data, it display the chinese character like äºŒé›„ 手冢治虫 司徒剑桥 岸本齐史. However, it display chinese character correctly on the webpage.

when user enter their information thru webpage, php save the data (with chinese character) into database and I use sqlyog to view the data and I see something like 手冢治虫 司徒剑桥

when I use java jdbc to save the data (with chinese character) into database and I use sqlyog to view the data and I see something like 四大名捕漫画

please further assist. Thanks !

regards,
Mark
Post Reply