From: Egor Bogatov Date: Wed, 12 Aug 2020 23:20:29 +0000 (+0300) Subject: [mono][Browser] Update ICU (#40387) X-Git-Tag: submit/tizen/20210909.063632~6037 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0db8ecbea291c09cfd84d7f33ea049f5c0cec94f;p=platform%2Fupstream%2Fdotnet%2Fruntime.git [mono][Browser] Update ICU (#40387) --- diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index ea4afb6..78762c5 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -4,9 +4,9 @@ https://github.com/dotnet/standard cfe95a23647c7de1fe1a349343115bd7720d6949 - + https://github.com/dotnet/icu - f58ab86d7e07a66ea189859f298843ccf41a0914 + 8bd04d98c75cc7d8ac9026eab2c63e50294b0552 diff --git a/eng/Versions.props b/eng/Versions.props index 02bd975..807c238 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -147,7 +147,7 @@ 5.0.0-preview.3.20403.5 - 5.0.0-preview.8.20403.1 + 5.0.0-preview.8.20404.1 9.0.1-alpha.1.20403.1 9.0.1-alpha.1.20403.1 diff --git a/src/libraries/Common/tests/Tests/System/StringTests.cs b/src/libraries/Common/tests/Tests/System/StringTests.cs index 74ceefc..8ea5bba 100644 --- a/src/libraries/Common/tests/Tests/System/StringTests.cs +++ b/src/libraries/Common/tests/Tests/System/StringTests.cs @@ -7312,8 +7312,13 @@ namespace System.Tests Assert.False(s.IsNormalized(), "String should be not normalized when checking with the default which same as FormC"); Assert.False(s.IsNormalized(NormalizationForm.FormC), "String should be not normalized when checking with FormC"); Assert.False(s.IsNormalized(NormalizationForm.FormD), "String should be not normalized when checking with FormD"); - Assert.False(s.IsNormalized(NormalizationForm.FormKC), "String should be not normalized when checking with FormKC"); - Assert.False(s.IsNormalized(NormalizationForm.FormKD), "String should be not normalized when checking with FormKD"); + + if (PlatformDetection.IsNotBrowser) + { + // Browser's ICU doesn't support FormKC and FormKD + Assert.False(s.IsNormalized(NormalizationForm.FormKC), "String should be not normalized when checking with FormKC"); + Assert.False(s.IsNormalized(NormalizationForm.FormKD), "String should be not normalized when checking with FormKD"); + } string normalized = s.Normalize(); // FormC Assert.True(normalized.IsNormalized(), "Expected to have the normalized string with default form FormC"); @@ -7326,23 +7331,38 @@ namespace System.Tests normalized = s.Normalize(NormalizationForm.FormD); Assert.True(normalized.IsNormalized(NormalizationForm.FormD), "Expected to have the normalized string with FormD"); - normalized = s.Normalize(NormalizationForm.FormKC); - Assert.True(normalized.IsNormalized(NormalizationForm.FormKC), "Expected to have the normalized string with FormKC"); + if (PlatformDetection.IsNotBrowser) + { + // Browser's ICU doesn't support FormKC and FormKD + normalized = s.Normalize(NormalizationForm.FormKC); + Assert.True(normalized.IsNormalized(NormalizationForm.FormKC), "Expected to have the normalized string with FormKC"); - normalized = s.Normalize(NormalizationForm.FormKD); - Assert.True(normalized.IsNormalized(NormalizationForm.FormKD), "Expected to have the normalized string with FormKD"); + normalized = s.Normalize(NormalizationForm.FormKD); + Assert.True(normalized.IsNormalized(NormalizationForm.FormKD), "Expected to have the normalized string with FormKD"); + } s = "hello"; Assert.True(s.IsNormalized()); Assert.True(s.IsNormalized(NormalizationForm.FormC)); Assert.True(s.IsNormalized(NormalizationForm.FormD)); - Assert.True(s.IsNormalized(NormalizationForm.FormKC)); - Assert.True(s.IsNormalized(NormalizationForm.FormKD)); + + if (PlatformDetection.IsNotBrowser) + { + // Browser's ICU doesn't support FormKC and FormKD + Assert.True(s.IsNormalized(NormalizationForm.FormKC)); + Assert.True(s.IsNormalized(NormalizationForm.FormKD)); + } + Assert.Same(s, s.Normalize()); Assert.Same(s, s.Normalize(NormalizationForm.FormC)); Assert.Same(s, s.Normalize(NormalizationForm.FormD)); - Assert.Same(s, s.Normalize(NormalizationForm.FormKC)); - Assert.Same(s, s.Normalize(NormalizationForm.FormKD)); + + if (PlatformDetection.IsNotBrowser) + { + // Browser's ICU doesn't support FormKC and FormKD + Assert.Same(s, s.Normalize(NormalizationForm.FormKC)); + Assert.Same(s, s.Normalize(NormalizationForm.FormKD)); + } } [Fact] diff --git a/src/libraries/System.Globalization.Extensions/tests/Normalization/NormalizationAll.cs b/src/libraries/System.Globalization.Extensions/tests/Normalization/NormalizationAll.cs index 1968f76..e62dfd8 100644 --- a/src/libraries/System.Globalization.Extensions/tests/Normalization/NormalizationAll.cs +++ b/src/libraries/System.Globalization.Extensions/tests/Normalization/NormalizationAll.cs @@ -51,11 +51,15 @@ namespace System.Globalization.Tests // Form D VerifyConformanceInvariant(NormalizationForm.FormD, part0, part1, part2, part3, part4); - // Form KC - VerifyConformanceInvariant(NormalizationForm.FormKC, part0, part1, part2, part3, part4); - - // Form KD - VerifyConformanceInvariant(NormalizationForm.FormKD, part0, part1, part2, part3, part4); + // Browser's ICU doesn't support FormKC and FormKD + if (PlatformDetection.IsNotBrowser) + { + // Form KC + VerifyConformanceInvariant(NormalizationForm.FormKC, part0, part1, part2, part3, part4); + + // Form KD + VerifyConformanceInvariant(NormalizationForm.FormKD, part0, part1, part2, part3, part4); + } } } } diff --git a/src/libraries/System.Globalization.Extensions/tests/Normalization/StringNormalizationTests.cs b/src/libraries/System.Globalization.Extensions/tests/Normalization/StringNormalizationTests.cs index 210914c..3ac46a8 100644 --- a/src/libraries/System.Globalization.Extensions/tests/Normalization/StringNormalizationTests.cs +++ b/src/libraries/System.Globalization.Extensions/tests/Normalization/StringNormalizationTests.cs @@ -4,6 +4,7 @@ using System; using System.Text; using Xunit; +using System.Collections.Generic; namespace System.Globalization.Tests { @@ -38,18 +39,28 @@ namespace System.Globalization.Tests AssertExtensions.Throws("strInput", () => StringNormalizationExtensions.IsNormalized(null)); } + public static IEnumerable NormalizeTestData() + { + yield return new object[] { "", NormalizationForm.FormC, "" }; + yield return new object[] { "\u00C4\u00C7", NormalizationForm.FormD, "A\u0308C\u0327" }; + yield return new object[] { "A\u0308C\u0327", NormalizationForm.FormC, "\u00C4\u00C7" }; + yield return new object[] { "\uFB01", NormalizationForm.FormC, "\uFB01" }; + yield return new object[] { "\uFB01", NormalizationForm.FormD, "\uFB01" }; + yield return new object[] { "\u1E9b\u0323", NormalizationForm.FormC, "\u1E9b\u0323" }; + yield return new object[] { "\u1E9b\u0323", NormalizationForm.FormD, "\u017f\u0323\u0307" }; + + if (PlatformDetection.IsNotBrowser) + { + // Browser's ICU doesn't support FormKC and FormKD + yield return new object[] { "\uFB01", NormalizationForm.FormKC, "fi" }; + yield return new object[] { "\uFB01", NormalizationForm.FormKD, "fi" }; + yield return new object[] { "\u1E9b\u0323", NormalizationForm.FormKC, "\u1E69" }; + yield return new object[] { "\u1E9b\u0323", NormalizationForm.FormKD, "\u0073\u0323\u0307" }; + } + } + [Theory] - [InlineData("", NormalizationForm.FormC, "")] - [InlineData("\u00C4\u00C7", NormalizationForm.FormD, "A\u0308C\u0327")] - [InlineData("A\u0308C\u0327", NormalizationForm.FormC, "\u00C4\u00C7")] - [InlineData("\uFB01", NormalizationForm.FormC, "\uFB01")] - [InlineData("\uFB01", NormalizationForm.FormD, "\uFB01")] - [InlineData("\uFB01", NormalizationForm.FormKC, "fi")] - [InlineData("\uFB01", NormalizationForm.FormKD, "fi")] - [InlineData("\u1E9b\u0323", NormalizationForm.FormC, "\u1E9b\u0323")] - [InlineData("\u1E9b\u0323", NormalizationForm.FormD, "\u017f\u0323\u0307")] - [InlineData("\u1E9b\u0323", NormalizationForm.FormKC, "\u1E69")] - [InlineData("\u1E9b\u0323", NormalizationForm.FormKD, "\u0073\u0323\u0307")] + [MemberData(nameof(NormalizeTestData))] public void Normalize(string value, NormalizationForm normalizationForm, string expected) { if (normalizationForm == NormalizationForm.FormC) diff --git a/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs b/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs index 84cc05e..bf04230 100644 --- a/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs +++ b/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs @@ -177,13 +177,18 @@ namespace System.Globalization.Tests Assert.Equal(expected, new RegionInfo(name).ISOCurrencySymbol); } - [Theory] - [InlineData("en-US", new string[] { "$" })] - [InlineData("zh-CN", new string[] { "\u00A5", "\uffe5" })] // \u00A5 is Latin-1 Supplement(Windows), \uffe5 is Halfwidth and Fullwidth Forms(ICU) - public void CurrencySymbol(string name, string[] expected) + [Fact] + public void CurrencySymbol() { - string result = new RegionInfo(name).CurrencySymbol; - Assert.Contains(result, expected); + Assert.Equal("$", new RegionInfo("en-US").CurrencySymbol); + if (PlatformDetection.IsNotBrowser) + { + Assert.Contains(new RegionInfo("zh-CN").CurrencySymbol, new string[] { "\u00A5", "\uffe5" }); + } + else + { + Assert.Equal("CNÂ¥", new RegionInfo("zh-CN").CurrencySymbol); + } } [Theory] @@ -218,7 +223,16 @@ namespace System.Globalization.Tests Assert.Equal(geoId, ri.GeoId); Assert.True(currencyEnglishName.Equals(ri.CurrencyEnglishName) || alternativeCurrencyEnglishName.Equals(ri.CurrencyEnglishName), "Wrong currency English Name"); - Assert.Equal(currencyNativeName, ri.CurrencyNativeName); + + if (PlatformDetection.IsBrowser) + { + // Browser's ICU doesn't support CurrencyNativeName + Assert.Equal(currencyEnglishName, ri.CurrencyNativeName); + } + else + { + Assert.Equal(currencyNativeName, ri.CurrencyNativeName); + } Assert.Equal(threeLetterISORegionName, ri.ThreeLetterISORegionName); Assert.Equal(threeLetterWindowsRegionName, ri.ThreeLetterWindowsRegionName); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/Normalization.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/Normalization.Icu.cs index 5cd1f1d..cfe698f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/Normalization.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/Normalization.Icu.cs @@ -100,6 +100,13 @@ namespace System.Globalization { Debug.Assert(strInput != null); + + if (OperatingSystem.IsBrowser() && (normalizationForm == NormalizationForm.FormKC || normalizationForm == NormalizationForm.FormKD)) + { + // Browser's ICU doesn't contain data needed for FormKC and FormKD + throw new PlatformNotSupportedException(); + } + if (normalizationForm != NormalizationForm.FormC && normalizationForm != NormalizationForm.FormD && normalizationForm != NormalizationForm.FormKC && normalizationForm != NormalizationForm.FormKD) {