Summary of the problems of UTF-8 in Web development

Source: Internet
Author: User
If a website needs to be internationalized, it needs to convert the code from GB2312 to a UTF-8, there are many problems to note, if not completely converted, there will be a lot of coding problems!

If a website needs to be internationalized, it needs to convert the code from GB2312 to a UTF-8, there are many problems to note, if not completely converted, there will be a lot of coding problems!

There are five main aspects:

I. HTML page to UTF-8 encoding problem

2. PHP page to UTF-8 encoding problem

III. problem of using UTF-8 encoding in MYSQL database

4. JS-related UTF-8 coding problems

5. UTF-8 coding problems related to FLASH

I. HTML page to UTF-8 encoding problem

1. inAfter,Add a line before: </p> <meta http-equiv = 'content-type' Content = 'text/html; charset = utf-8 '/> </p> <p> The sequence cannot be incorrect. you must add the <title> label before it. otherwiseIf there are Chinese characters, the title may be garbled!

2.html file encoding:

Click the editor menu: File-> save as, you can see the encoding of the current file, make sure that the file is encoded as: UTF-8, if it is ANSI, you need to change the encoding to: UTF-8.

3. HTML file header BOM:

When converting a file from another encoding to a UTF-8 encoding, sometimes a BOM label is added at the beginning of the file, and a BOM label may cause garbled characters in the browser when displaying Chinese characters.

To delete this BOM tag:

1. you can use Dreamweaver to open the file and save it again, removing the BOM tag!

2. you can open the file with EditPlus, and in the menu "preferences"-> "files"-> "UTF-8 identifier", set to "always delete signature", and then save the file, you can remove the BOM label!

4. WEB server UTF-8 coding problems:

If you have followed the steps listed above and still encountered Chinese garbled characters, check the encoding of your WEB server.

If you are using Apache, set charset in the configuration file to UTF-8 (only the method is listed here. For the specific format, see The apache configuration file ).

If you are using Nginx, set charset in nginx. conf to utf-8. For more information, see "charset gb2312;" or change it to "charset UTF-8 ;".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.