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:

<!-- HelpUtf8Chinese.html
#- Copyright 2009 (c) All Rights Reserved.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

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,, 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

 About This Book

 Introduction and Installation of PHP

 PHP Script File Syntax

 PHP Data Types and Data Literals

 Variables, References, and Constants

 Expressions, Operations and Type Conversions

 Conditional Statements - "if" and "switch"

 Loop Statements - "while", "for", and "do ... while"

 Function Declaration, Arguments, and Return Values

 Arrays - Ordered Maps

 Interface with Operating System

 Introduction of Class and Object

 Integrating PHP with Apache Web Server

 Retrieving Information from HTTP Requests

 Creating and Managing Sessions in PHP Scripts

 Sending and Receiving Cookies in PHP Scripts

 Controlling HTTP Response Header Lines in PHP Scripts

 Managing File Upload

 MySQL Server Connection and Access Functions

 Functions to Manage Directories, Files and Images

 SOAP Extension Function and Calling Web Services

 SOAP Server Functions and Examples

 Localization Overview of Web Applications

Using Non-ASCII Characters in HTML Documents

 Basic Rules of Using Non-ASCII Characters in HTML Documents

 French Characters in HTML Documents - UTF-8 Encoding

 French Characters in HTML Documents - ISO-8859-1 Encoding

Chinese Characters in HTML Documents - UTF-8 Encoding

 Chinese Characters in HTML Documents - GB2312 Encoding

 Characters of Multiple Languages in HTML Documents

 Using Non-ASCII Characters as PHP Script String Literals

 Receiving Non-ASCII Characters from Input Forms

 "mbstring" Extension and Non-ASCII Encoding Management

 Managing Non-ASCII Character Strings with MySQL Servers

 Parsing and Managing HTML Documents

 Configuring and Sending Out Emails

 Image and Picture Processing

 Managing ZIP Archive Files

 Managing PHP Engine and Modules on macOS

 Managing PHP Engine and Modules on CentOS

 Archived Tutorials


 Full Version in PDF/EPUB