I got a little stuck on this…

Have you ever migrated an old EUC-JP or Shift JIS site to a new server and ended up with garbled characters? I have. In fact, that happened to me this morning.

At first I thought, “Sure, DefaultCharSet,” and quickly edited the files under /etc/apache2/sites-available/, but the change was not applied! Even when I checked with Chrome Developer Tools, it was still being sent as UTF-8.

“Why???”

I spent quite a while puzzling over it.

The actual reason was that the site used PHP. PHP overrides Apache settings and the like with the charset specified in php.ini. So, adding the following to the configuration file for the relevant Apache virtual host gives PHP an instruction and resolves the issue.

php_value default_charset EUC-JP

That makes sense. So that I do not get stuck on this again, I am leaving this here as a note.

Related posts