The function of this paper is to avoid the garbled problem caused by the use of UTF-8 encoding in an all-round way, does not contain the specific garbled solution and the content of encoding conversion. For more information about UTF-8 encoding, see PHP regular expressions matching Chinese characters in UTF-8
1. Editor: Do not use any Microsoft editor, what front page, Web Designer, notepad, WordPad or something, can be lost all open, because these editors will generate BOM in front of your UTF-8 document, BOM specific instructions, can be found here, when I directly take notepad to cover the original file, resulting in a large number of code damage, the memory is still new.
2. MySQL database: When creating databases, creating tables, and creating fields (note that there are three fields), you must select utf8_general_ci sorting format (Collation) and use mysql_connect () in PHP () after the function connects data, you need to add the following sentence:
Mysql_query ('set names "utf8 "');
3. PHP:
Use the mb library instead of the iconv library.
Use preg instead of ereg to process characters.
When using the htmlentities () function, the html_entity_decode () function must contain the third parameter:
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<? Php
$ Str = "<a href = 'test'> Chinese </a> ";
Echo htmlentities ($ str, ENT_COMPAT, "UTF-8"); // Display (in the source code) & lt; a href = 'test' & gt; Juan?