MySQL table and field encoding format error
First, database, table, field encoding format are Latin1 (iso-8859-1). When the data is saved to the database, the Chinese display is garbled.
Workaround:
1. Add the encoding format to the Access database connection string:
<add key= "mysqlconnectionstring" value= "server=127.0.0.1; port=3306; UID=TTT; pwd=ttt;database=test_db;innercharacterset=gb2312;charset=gb2312 "/>
There is no problem with the information obtained in Chinese.
Note: Use the GB2312 encoding to add the Chinese information, read also use the same encoding format, that is, access to the encoding format to be consistent, otherwise obtained is garbled.
Second, if the obtained string is Latin1 encoded, in C # can do the following conversions:
<summary>
Latin1 (iso-8859-1) Turn gb2312 Chinese
</summary>
<param name= "str" ></param>
<returns></returns>
public static string Latin1toutf8 (String str) {
The gb2312 here depends on the character encoding set in the MySQL connection string.
Return encoding.getencoding ("gb2312"). GetString (encoding.getencoding ("iso-8859-1"). GetBytes (str));
}
MySQL table and field encoding format error