Enable full Encodings on Windows Console by Default (dotnet/corefx#14649)

* Enable full Encodings on Windows Console by Default

by default .NetCore doesn't enable the codepage encoding and the app has to opt-in to the full encoding through the call
	Encoding.RegisterProvider(CodePagesEncodingProvider.Instance)
This was not a good stand for the Console specially on Windows as the Console always using encoding which is not supported by default and we had to fallback using UTF8.
In this change we are supporting the full OS encoding on Console and System.Diagnostics.Process without bringing the big encoding size cost (which is 600+ KB). The way we support it is we create an OSEncoding class wrapper which will call the OS instead of using our own encoding data.
The only restriction we’ll have is cannot use encoding fallback with OSEncoding as this will be very slow and not intuitive. But this is acceptable as usually apps don’t use the console encodings for such fallback operation. But if anyone want to do that can still register the encoding provider and get full support.

* Add Encoder/Decoder to OSEncoding in Console

* fix misspelling

* Some fixes and adding tests

* Fix corner case when buffer has only one high surrogate char


Commit migrated from https://github.com/dotnet/corefx/commit/bb068f3be887ed34e7f8bedc4c12ec4284884441
This commit is contained in:
Tarek Mahmoud Sayed authored and GitHub committed 2016-12-27 13:47:04 -08:00
1 parent e467217e7c
commit d198bb4457
17 files changed
+1046 -31

No files matched your search

@@ -50,6 +50,9 @@
</ItemGroup>
<ItemGroup Condition=" '$(TargetsWindows)' == 'true' ">
<Compile Include="System\Text\CodePagesEncodingProvider.Windows.cs" />
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.Encoding.Constants.cs">
<Link>Common\Interop\Windows\kernel32\Interop.Encoding.Constants.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Windows\Interop.Libraries.cs">
<Link>Common\Interop\Windows\Interop.Libraries.cs</Link>
</Compile>