The following articles mainly introduce the two misunderstandings in the C # operation regarding the MySQL Chinese garbled solution, and the specific description of the correct solution for MySQL Chinese garbled characters in C # operations. The following is the detailed description of the article.
C # misunderstanding of the solution for operating MySQL with Chinese garbled characters:
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.
C # misunderstanding of the solution for operating MySQL with Chinese garbled characters: one of them is that we all want to use utf8, but UTF8 is not ideal in Chinese processing, select/Update/Insert are garbled;
C # misunderstanding of the solution for operating MySQL Chinese garbled characters: 2. gbk character set is much larger than gb2312, which is the second preferred character set, but after the Server/Database is set to GBK character set, the connection fails in the Program (not support), not to mention the operation;
C # final solution for operating MySQL Chinese garbled solutions:
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)
The above content is an introduction to the final solution of the MySQL Chinese garbled solution for C # operations. I hope you will gain some benefits.