Jump to content

Display chinese charaters in webpage


abdfahim

Recommended Posts

HTML entities won't work - Hanzi are not entities, they are actual characters.

 

If you want them to show on all OSes, for all users, the only real way you can do it is with images. The majority of windows users don't have East Asian language fonts installed on their PCs, so their PC won't render the characters (I think Mac ships with East Asian fonts installed). As such, the only way to guarantee that a user will be able to see the characters is to make them an image.

 

However if you are speaking of actually building a website with proper Chinese characters (read:not images), and recognize that users without the fonts installed will not be able to see the characters, then you are best off using a charset that support Chinese characters.

 

Which charset to use basically is decided by two things:

* If you are making a site that is not Chinese, but will display Chinese characters, you should use UTF-8

* If you are making a Chinese site, you should use a Chinese charset (there are a few, I don't know which one is the best - I do Japanese sites, not Chinese).

 

Once you have decided on the Charset you want to use, you need to make sure all of the following are set to that charset:

* The database (if you are using one)

* The PHP default charset (if you are doing a dynamic site)

* The document charset (when you save documents, you can save them in a certain charset. Some software buries this selection way down deep, so you may have to search for it)

* The charset metatag in your HTML document (this is not the same as the last point. This is an actual HTML tag in your document).

 

 

Link to comment
Share on other sites

Thanks haku, that was informative. I have some concern though

 

1) I have to use chinese font in form elements also (as in select options, input text etc.), so image concept is not possible I guess.

2) The PHP default charset, is it possible to change by me with ini_set? Because I dont know whether the hosting provider allow this to change.

3) I am using UTF-8, I hope that'll work.

 

Now, my major concern is, in my php editor, whenever I paste any chinese word, it becomes "???". Is it a problem with my editor? How can I have a php variable with a chinese text inside while coding?

Link to comment
Share on other sites

I'm not 100% sure if you can change the php default charset with an ini_set. I always do it in the php.ini. I do know it can be set in an .htaccess file (if you are on a server setup that reads .htaccess files), but you'll have to do some searching for the specifics.

 

As to your other problem, it's one of two issues:

1) Either your text editor doesn't support Chinese characters or

2) Your document is saved in a charset that is non-compatible with Chinese characters (point 3/4 in my original post).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.