Dreamweaver Japanese PHP Frustrations

I’m posting this in the hope that it will save somebody from having to go through what I’ve just suffered, trying to get my Japanese-language website to display properly.

I have been trying to make a website using Japanese characters. Surprisingly, it was all going very well, everything seemed to work pretty much OK once I had stuck the requisite <META http-equiv=Content-Type content="text/html; charset=utf-8"> tag in there.

However, when I converted the site to PHP and modularised it, I had lots of problems with include files. I would paste some Japanese characters into the includes, in exactly the same way as I had done for the main pages, but when I checked the website all of the Japanese characters were replaced by question marks. I then re-opened the include file in Dreamweaver MX2004 and found that there too all my lovingly pasted Kanji had morphed into a long line of “?”s.

I searched in vain for a solution – lots of stuff on the web telling me how to make my web pages Japanese, but nothing dealing with mere snippets where I didn’t have the luxury of throwing in a UTF-8 header. Eventually I stumbled on the solution, while browsing through the Dreamweaver preferences. I went to Edit->Preferences->New Document and changed the default encoding to UTF-8. Then I created a new blank PHP document (switching settings didn’t seem to have any effect on the old documents, only on newly created ones), paste all of the code from the old PHP include file, then paste the Kanji in the relevant places, save it, and when all is done don’t forget to switch default coding back to Western European. Et voilà! My Japanese script looks like proper Japanese script, not like a row of question marks. Hurrah!