UTF8 turn into GBK

Source: Internet
Author: User
UTF8 turn into GBK

Using the Set names character set
Character_set_client
Character_set_result
Character_set_connection These three items are set to set names GBK in the cmd Black window, when the data file layer and the System Management layer are UTF8 in the cmd window when the data is fetched from the file through the data management layer and then arrives at Character_ Set_result there should be encoding conversion problems in this process do not turn from UTF8 to GBK? Well, if this conversion should be garbled,


Reply to discussion (solution)

Need, and your file code should be GBK.

If you have any CMD directly connected to the MySQL client operation, you don't need to, MySQL automatically converts the

If you are actually executing PHP under CMD, the output is determined by the PHP file encoding.

From the database to PHP is an IO, from PHP echo to CMD is also an IO, pay attention to the code changes before and after two IO

You say cmd, should be Windows Bar, Windows cmd By default is followed by the system encoding, such as Simplified Chinese windows its cmd default is cp936 (equivalent to GBK) encoding, this encoding can be made permanent changes through the registry, or the use of "chcp xxx" command temporarily changed , where xxx is the code number, 936 equivalent to gbk,65001 equivalent to Utf-8

At the beginning of cmd input chcp 65,001 back to the car, the cmd window becomes equivalent to the UTF-8 encoded output

Note: Cpxxx is a Microsoft-determined code, and the corresponding general-purpose encoding has a very slight difference, generally use does not involve the content of these differences, so the above is said to be "equivalent"

Upstairs to learn a silent collection

As long as your data field's connection proofing is in the Chinese series (GBK, Big5, UTF8, ucs-2, utf-16 ...)
Then you only need to set the names character set when you use it, and then you can do it in the character set you want.
The code conversion work is done by MySQL for you

  • Related Article

    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.