Unicode in PHP/HTML

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Echilon
Forum Newbie
Posts: 12
Joined: Fri Nov 25, 2005 4:11 am
Location: England
Contact:

Unicode in PHP/HTML

Post by Echilon »

I have a PHP script that uses MySQL to store entries. At the moment, the whole script is in English, but I've just sorted out a translation into Simplified Chinese. I know Chinese uses unicode, but I have absolutely no experience with working with it. At present, I'm using:

Code: Select all

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />

in the head of the outputted HTML, could I just change this to

Code: Select all

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
and have the English and Chinese versions work alongside each other, or would I need to change the output depending on the language selected? I'm also not sure about PHP and Chinese. All the language strings are defined as constants using

Code: Select all

define("CONSTANTNAME","Some text in English");
so would I be able to just copy and paste the Chinese translations in place of the English text, or would I need to do something extra? I'm using Verdana as the font face at the minute, but does it even support Chinese? I've noticed when I open the file the translator sent back with notepad, it displays fine, but when I open it with Context (http://context.cx), it displays as jibberish.

I'm really looking for some insight from someone who knows a bit more about this.

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You may need to do more than simply a <meta> tag. Specifically, you may need to add header() calls to specify character encoding form and various other settings. Lastly, you'll simply need to try it and see if it works.
Post Reply