UTF-8 Encoding Pages with GB18030 Characters

This section describes an error case where a UTF-8 encoding page contains GB18030 characters.

The most common errors occur on Chinese Web pages are some characters using encodings different than the page encoding setting. For example, a Web page is set with charset=utf-8. But some characters are entered in GB18030 encoding. In this case, those GB18030 characters will not be displayed correctly.

To show you this problem, I created this test Web page. The page is set with charset=utf-8 and most Chinese characters are entered in UTF-8 encoding. But some Chinese characters are entered in GB18030 encoding.

<html>
<!-- Hello-UTF-8-Error.html
#- Copyright (c) 2005 HerongYang.com. All Rights Reserved.
-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<body>
<b>Chinese characters in UTF-8</b><br/>
Simplified characters: 简体中文网页<br/>
Traditional characters: 繁體中文網頁<br/>
<br/>
<b>Error: GB13080 characters included in a UTF-8 page</b><br/>
Simplified characters: ??????<br/>
</body>
</html>

As expected, this Web page, http://localhost/Hello-UTF-8-Error.html, does not display those GB18030 characters correctly:

Chinese Web Page using UTF-8 with GB18030 Characters
Chinese Web Page using UTF-8 with GB18030 Characters

Table of Contents

 About This Book

 PHP Installation on Windows Systems

 Integrating PHP with Apache Web Server

charset="*" - Encodings on Chinese Web Pages

 Chinese Character Set Encoding Options

 HTML Document Travel Path

 Chinese Web Pages with UTF-8 Encoding

 Chinese Web Pages with GB18030 Encoding

 Chinese Web Pages with Big5 Encoding

UTF-8 Encoding Pages with GB18030 Characters

 Chinese Characters in PHP String Literals

 Multibyte String Functions in UTF-8 Encoding

 Input Text Data from Web Forms

 Input Chinese Text Data from Web Forms

 MySQL - Installation on Windows

 MySQL - Connecting PHP to Database

 MySQL - Character Set and Encoding

 MySQL - Sending Non-ASCII Text to MySQL

 Retrieving Chinese Text from Database to Web Pages

 Input Chinese Text Data to MySQL Database

 Chinese Text Encoding Conversion and Corruptions

 Archived Tutorials

 References

 Full Version in PDF/EPUB