I'm sending japanese characters in one field of one table of a MySQL database.
I use addslashes() and htmlspecialchars() on the variable, and the collation of the whole database is Shift_JIS (the most common encoding in Japan, and the one that my application is set to on every page.
But, when I pull the data out of the table and display it, it is just garbled nonsense - ie., I am losing the Japanese when I put it into the database. I know it is garbled as soon as it goes in as I have checked using phpMyAdmin.
Does anyone know a way I can at least get the japanese characters converted to numerical entities to be saved like that?
Some may suggest using UTF-8, but I don't know how to get my japanese OS to let me input japanese using that encoding - I think I am stuck with Shift-JIS.
I really hope someone can give an amateur like me some pointers or help with this problem.
when you use htmlspecialchars() are your setting the encoding version?
htmlspecialchars($string,"utf-8");
See http://uk2.php.net/htmlspecialchars
I wasn't setting the encoding version, no.
I tried that, as you suggested it, but when I specify "shift-jis" I get an error message that the parameter is expected to be 'long, string', whatever that is supposed to mean.
I also tried with htmlentities(), but my Japanese is still getting garbled.
Does anyone have any more ideas?
Worked it out... needed to use html_entity_decode() to get the Japanese characters back again.
Out of curiosity... this is 5.* ver of Mysql you are using goofy2feet? Correct?
No, actually, my server provider has MySQL version 4.1.20-standard as I discovered when I tried using a string function from the php documentation for version 5 and got an 'unrecognized function' error.
Should this make me think they're not really on top of their game?