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...
The Portable Class Library project enables you to write and build managed assemblies that work on more than one . NET Framework platform. You can create classes that contain code you wish to share across many projects, such as shared business logic, and then reference those classes from different types of projects.
Portable Class Libraries (PCL)
According to the documentation here: Encoding.GetEncoding Method (Int32), you can use Encoding.GetEncoding(0) to get the default encoding.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With