I need to create System.Encoding for 1251 codepage.
On my russian Windows I use
Encoding encoding = Encoding.Default
I am afraid this will produce different results depending on Windows
Correct, you will get different results on different machines if you use Encoding.Default
.
If you want a specific codepage, you can use Encoding.GetEncoding:
Encoding encoding = Encoding.GetEncoding("windows-1251");
For .NET Core you also need to reference the System.Text.Encoding.CodePages package and then use Encoding.RegisterProvider:
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
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