Windows -1252不支持编码名称 [英] Windows -1252 is not supported encoding name
本文介绍了Windows -1252不支持编码名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Windows 10通用应用程序和ARM CPU为Raspberry Pi创建应用程序.我在编码时收到以下错误:
I am working with windows 10 universal App and the ARM CPU to create apps for the Raspberry Pi. I get the following error with encoding:
其他信息:'windows-1252'不是受支持的编码名称.有关定义自定义编码的信息,请参见Encoding.RegisterProvider方法的文档.
Additional information: 'windows-1252' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
private async void Login(string passcode)
{
try
{
MySqlConnection conn = new MySqlConnection("Server=...");
MySqlCommand cmd;
conn.Open();
cmd = new MySqlCommand("Select * from ...");
var dr = cmd.ExecuteReader();
int count = 0;
while (dr.Read())
count += 1;
var dialog = new MessageDialog((count == 1) ? "Logged In" : "Error");
await dialog.ShowAsync();
}
catch (Exception ex)
{
var dialog = new MessageDialog(ex.Message);
await dialog.ShowAsync();
}
finally { conn.Close(); }
}
}
我在这行代码中得到了错误
I get the error in this line of code
dr = cmd.ExecuteReader();
在我以前把它拿进去
conn.open();
但是我能够通过添加来解决
But I was able to solve it by adding
charset=utf8
连接字符串.
如何解决此错误?
推荐答案
我通过添加
System.Text.EncodingProvider ppp = System.Text.CodePagesEncodingProvider.Instance;
Encoding.RegisterProvider(ppp);
这篇关于Windows -1252不支持编码名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文