UTF-8 confusion
Posted: Tue Nov 08, 2011 8:25 am
So I thought I had the conversion of a db to UTF-8 figured out. But I don't or at least I'm confused on how to use it. I've converted the db over to UTF-8 both in collation and charset.
When I try to enter a UTF-8 type character say c2 b4 (or ´ the ACUTE ACCENT) it works fine in phpmyadmin. When I do a mysqldump and hexdump the data i see it in the insert string as c2 b4.
However when I try to insert it via php (5.3) with something like this:
[text]UPDATE `database`.`table` SET `content` = 'You don\xc2\xB4t know UTF-8?' WHERE `table`.`id` =1;[/text]
Which when I save this string to a file system (utf-8) and use hexdump it looks right with c2 b4. But looking in the database I get [text]You don´t know UTF-8?[/text]
Where ´ is c3 82 42 34 and hexdump of the mysqldump file shows it as "You don..B4t know" where the B4 seems to hint at the original c2 b4 two bytes.
Any ideas?
If i just use B4 it works, but that isn't UTF-8 is it?
[text]UPDATE `database`.`table` SET `content` = 'You don\xB4t know UTF-8?' WHERE `table`.`id` =1;[/text]And when I hexdump this it shows up as c2 b4 and looks correct.
When I try to enter a UTF-8 type character say c2 b4 (or ´ the ACUTE ACCENT) it works fine in phpmyadmin. When I do a mysqldump and hexdump the data i see it in the insert string as c2 b4.
However when I try to insert it via php (5.3) with something like this:
[text]UPDATE `database`.`table` SET `content` = 'You don\xc2\xB4t know UTF-8?' WHERE `table`.`id` =1;[/text]
Which when I save this string to a file system (utf-8) and use hexdump it looks right with c2 b4. But looking in the database I get [text]You don´t know UTF-8?[/text]
Where ´ is c3 82 42 34 and hexdump of the mysqldump file shows it as "You don..B4t know" where the B4 seems to hint at the original c2 b4 two bytes.
Any ideas?
If i just use B4 it works, but that isn't UTF-8 is it?
[text]UPDATE `database`.`table` SET `content` = 'You don\xB4t know UTF-8?' WHERE `table`.`id` =1;[/text]And when I hexdump this it shows up as c2 b4 and looks correct.