Try to fix issues with Unicode on big endian OSes (dotnet/coreclr#18254)
authorCalvin <calvin@cmpct.info>
Sun, 3 Jun 2018 02:03:12 +0000 (23:03 -0300)
committerJan Kotas <jkotas@microsoft.com>
Sun, 3 Jun 2018 02:03:12 +0000 (19:03 -0700)
commitbf2b0114f91900bc5ad9dccd8ee7c32f85815510
treedd1b8a5ee83424c0fa4f6233786d1e7865e2e3b3
parent5d42f5942e2196db81fbf79e60d6f3652541b2a1
Try to fix issues with Unicode on big endian OSes (dotnet/coreclr#18254)

Mono had some patches in their fork of referencesource to resolve
issues on big endian. Essentially, compile-time endianness handling
is no good for big endian platforms, because they have to consume a
Monolite intended for all platforms in order to bootstrap. So then,
all big endian platforms are now consuming a bootstrap tarball made
on little endian systems, and bad things happen as a result.

This makes it so that endianness is checked at runtime by using
System.BitConverter.IsLittleEndian, not by a compiler definition.

This integrates mono/mono@1f9b218 and mono/mono@92cec46, which won't
apply cleanly to current CoreFX.

mono/monodotnet/coreclr#8679 may get fixed by this, but as the comments say,
there could be more patches missing. This just integrates the
patches known to me on UnicodeEncoding and UTF8Encoding.

Commit migrated from https://github.com/dotnet/coreclr/commit/6da69e6536a596a6b2141374bd2c9e96bdebbc62
src/libraries/System.Private.CoreLib/src/System/Text/UTF8Encoding.cs
src/libraries/System.Private.CoreLib/src/System/Text/UnicodeEncoding.cs