c#latin1_swedish_ci为unicode

时间:2013-01-22 13:16:20

标签: c# mysql

我有一个带latin1_swedish_ci的MySQL数据库,当我尝试选择某些东西时,选择返回这样的字符串:

ტáƒáƒ‘ი მáƒáƒ™áƒ’უáƒáƒ˜áƒ áƒ˜, კირსტენ დáƒáƒœáƒ¡áƒ¢áƒ˜, ჯეიმს ფრáƒáƒœáƒ™áƒ

这是我的代码:

string db = "server=xxx;database=xxx;uid=xxx;password=xxx;charset=utf8;";
MySqlConnection con = new MySqlConnection(db);
con.Open();
MySqlCommand cmd = new MySqlCommand("SET NAMES utf8; SELECT * FROM `xxx`", con);
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
     string source = reader.GetString("xxx");
     byte[] utf8Bytes = Encoding.UTF8.GetBytes(source);
     byte[] isoBytes = Encoding.Convert(Encoding.ASCII, Encoding.UTF8, utf8Bytes);
     string uf8converted = Encoding.UTF8.GetString(isoBytes);    
}

我做错了什么?请帮忙。

1 个答案:

答案 0 :(得分:0)