Windows -1252 does not support name encoding

I work with a universal Windows 10 application and an ARM processor to create applications for the Raspberry Pi. I get the following encoding error:

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 an error in this line of code

 dr = cmd.ExecuteReader(); 

Before I got it in

 conn.open(); 

But I was able to solve this by adding

 charset=utf8 

to the connection string.

How can I solve this error?

+7
source share
2 answers

I solved this problem by adding

 System.Text.EncodingProvider ppp; ppp = System.Text.CodePagesEncodingProvider.Instance; Encoding.RegisterProvider(ppp); 
+13
source

From .NET Core 2.2, I had to install the following two packages through Nuget:

System.Text.Encoding | Codepages

(System.Text.Encoding & System.Text.Encoding.CodePages)

Then you must install it before using the libraries:

  using System.Text; … { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); ... } 
+1
source

All Articles