Encoding.GetEncoding can’t work in UWP app

We need to use the CodePagesEncodingProvider to register extended encodings included in that specific provider. See CodePagesEncodingProvider Class

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Encoding.GetEncoding("windows-1254");

Ref https://msdn.microsoft.com/en-us/library/system.text.encodingprovider(v=vs.110).aspx

The .NET Framework Class Library provides one static property,
P:System.Text.CodePagesEncodingProvider.Instance, that returns an
EncodingProvider object that makes the full set of encodings available
on the desktop .NET Framework Class Library available to .NET Core
applications.

The related thread in MSDN forum: Encoding.RegisterProvider — How to use?

Leave a Comment