问题描述:

I recently ditched godaddy shared hosting and moving to a VPS for my site, which uses Japanese. Previously I was having no trouble inputting Japanese via PHP into MySQL and then displaying it. I moved the site using cpanel backup and restore. Everything went pretty smoothly, but all the Japanese data in the database no comes out like this:

?J???�?_?[??�z??

I did some poking around on utf8 encoding, and made some changes, but I still can't get it to display.

However, when I insert new data into the database from the same PHP pages, I get nice Japanese information displayed back to me.

Is it possible that in the move the Japanese data was somehow corrupted?

If so, can I recover it?

Also, will regular MySQL backups prevent against this from happening in the future? If a backup and restore corrupted my data (in Japanese only, not the English parts) I feel a lack of confidence in my ability to rely on backups.

The old database includes data which looks like this for the Japanese:

ƒJƒŒƒ“ƒ_[‚ð”z‚é

Clearly different than what showed up when I restored the cpanel. I tried copy-pasting this into the new MySQL database but still get garbled characters

网友答案:

?J???�?_?[??�z?? sounds like the wrong charset in the <meta ...> in html.

Is ƒJƒŒƒ“ƒ_[‚ð”z‚é supposed to be カレンダ[を配る? If so, then it was encoded sjis or cp932.

Please do this to further diagnose things:

SHOW CREATE TABLE

SELECT col, hex(col) FROM tbl WHERE ...

and tell us what you think that text should be.

From there, I may be able to tell you how to unravel things.

相关阅读:
Top