How can I determine the default encoding in a portable class library?

Viewed 1783

With .NET 4.6 I can detect the current codepage with:

System.Text.Encoding.Default

Now I'm trying to port a class library that is reading files from a standard class library to a portable class library, supporting ASP.NET Core 5. With this configuration, Encoding.Default is not availiable.

Of course, any recent file should be saved in UTF-8 encoding, but I can not ensure that all files are stored in this encoding.

Is there another way to get the default codepage?

I looked at the reference source and found that Encoding.Default is implemented (more ore less) with an Win32 Api call...

1 Answers
Related