PHP Tutorials - Herong's Tutorial Examples - v5.16, by Herong Yang
Chinese Characters in HTML Documents - UTF-8 Encoding
This section provides a tutorial example on how enter and use Chinese characters in HTML documents using Unicode UTF-8 encoding. The HTML document should include a meta tag with charset=utf-8 and be stored in UTF-8 format.
Now let's play with Chinese characters. They are definitely harder to work with than French characters. My first example shows you how to handle Chinese characters in HTML documents with UTF-8 encoding.
1. On a Windows system, run Start > All Programs > Accessories > Notepad.
2. In Notepad, enter the following HTML document:
<html> <!-- HelpUtf8Chinese.html #- Copyright 2009 (c) HerongYang.com. All Rights Reserved. --> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <body> <b>说明</b><br/> 这是一份非常间单的说明书…<br/> </body> </html>
3. As I mentioned earlier in this book, entering Chinese characters is not an easy job. You need to use a Chinese Windows system, or a Chinese input tool on a non-Chinese Windows system. If you don't have any Chinese input tool, you can simply go to the Yahoo Chinese Web site, http://www.yahoo.com.cn/, copy some Chinese characters, and paste them into Notepad. The Yahoo Chinese Web site is encoded in UTF-8.
4. Select menu File > Save as. Enter the file name as HelpUtf8Chinese.html. Select "UTF-8" in the Encoding field and click the Save button.
5. Copy HelpUtf8Chinese.html to c:\apache\htdocs. Make sure your Internet Information Service is running the local default Web site.
6. Now run Internet Explorer (IE) with http://localhost/HelpUtf8Chinese.html. Your should see the Chinese characters displayed correctly.
7. On the IE window, select menu View > Encoding. You should see UTF-8 is selected.
Table of Contents