C # mistakes and answers to MySQL Chinese garbled characters

Source: Internet
Author: User

This article mainly describes the actual solution for operating MySQL Chinese garbled characters in C # And the misunderstanding that is easy to get into in actual operations. The following describes the specific solution, if you are interested, you can click the following articles to view them.

Misunderstanding:

In the past few days, the optional encoding methods for searching online resources are: gb2312, gbk, and utf8 support dual-byte encoding types. This is not the case in actual experiments.

A. We all want to use utf8, but UTF8 is not ideal for Chinese processing, and Select, Update, and Insert are garbled;

B. the gbk character set is much larger than the gb2312 character set. It is the second preferred character set. However, after the Server/Database is set to the GBK character set, the connection in the program fails (not support), not to mention the operation;

Final Solution:

1. gb2312 Encoding

2. Set the default encoding in the my. ini file.

Add or modify default_charater_set = gb2312 in the [optimal combination of MySQL (and PHP)] and [optimal combination of MySQL (and PHP) d] configuration segments.

3. When creating a database, use gb2312 encoding.

4. When creating a table, use gb2312 encoding and gb2312_chines_ci for Collation (gb2312_bin is not tested)

5. Set the encoding for specific fields that need to store Chinese characters using gb2312 and gb2312_chines_ci for Collation (gb2312_bin is not tested)

Improvement:

If you do need to store gbk encoded characters, run set names gbk after the connection is successful.

There are a total of related topics 100

The above content is an introduction to the solution for C # To operate MySQL with Chinese garbled characters. I hope you will gain some benefits.

The above content is the description of the solution for operating MySQL in C # With Chinese garbled characters. I hope it will help you in this regard.

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.