Encoding.GetEncoding can't work in UWP app

前端 未结 1 1728
我在风中等你
我在风中等你 2020-12-01 18:30

I need to encode some text files for native characters.

In my Windows 8.1 Store app, I could use Encoding.GetEncoding() method normally:



        
相关标签:
1条回答
  • 2020-12-01 18:48

    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?

    0 讨论(0)
提交回复
热议问题