public static string get_uft8 (String unicodestring)
{
UTF8Encoding UTF8 = new UTF8Encoding ();
byte[] encodedbytes = UTF8. GetBytes (unicodestring);
String decodedstring = UTF8. GetString (encodedbytes);
return decodedstring;
}
This way, I'm taking Big5 conversion gb2312 as an example.
Encoding Big5 =encoding.getencoding ("Big5");
Encoding gb2312 = encoding.getencoding ("gb2312");
Byte[] big5b= Big5. GetBytes ("No Regrets!" ");
That's the point.
Byte[] gb2312b= Encoding.convert (big5,gb2312,big5b);
String strGb2312 = gb2312. GetString (gb2312b)
1: Add character encoding declaration in link character
<add key= "Mysqlconstr" value= "userid=root; Allow Zero datetime=true; Charset=utf8; Host=125.*.*.*;D Atabase=dbname; password=123456 "/>
String connectiontext = "Server=139.222.313.153;database=testsys; User=root; password=1123456; Charset=utf8; ";
Explain to MySQL that my character encoding is gb2312 or Utf-8, do not be mistaken.
As long as you are connected to MySQL, set the character set correctly, no matter what format the database is used to encode, you can get the correct result. Some people may think that the character set when writing data is required to be consistent with reading data, in fact it is completely unnecessary. The only thing that the program has to do is tell MySQL what character set is currently being used for MySQL operation. Because MySQL will automatically do the following conversion work:
The character set used to write the database--the character set of the data and the character set for reading the data.
C # coding problems and C # coding for MySQL plug-in data