Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blazor WASM] String comparison, ignoring case #24513

Closed
Timka654 opened this issue Aug 2, 2020 · 3 comments
Closed

[Blazor WASM] String comparison, ignoring case #24513

Timka654 opened this issue Aug 2, 2020 · 3 comments
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly

Comments

@Timka654
Copy link

Timka654 commented Aug 2, 2020

Details
.NET 5.0.0-preview.7.20365.19
Blazor client side (WASM)

Problem
If i'm compare string ignore case on any methods (IndexOf, Contains, etc) with ignore case options have not found result on Russian language, maybe in other languages too

Sample
For this sample i'm using word "Test" and his equal in russian language word "Тест"

        List<string> list = new List<string>()
{
"Test",
"Тест",
};

        bool Exists1(string text) => list.Any(x => x.Contains(text, StringComparison.CurrentCultureIgnoreCase));
        bool Exists2(string text) => list.Any(x => x.Contains(text, StringComparison.InvariantCultureIgnoreCase));
        bool Exists3(string text) => list.Any(x => x.Contains(text, StringComparison.OrdinalIgnoreCase));
        bool Exists4(string text) => list.Any(x => x.ToLower().Contains(text.ToLower()));

        void Test()
        {
            bool result1_0 = Exists1("Test"); // true
            bool result1_1 = Exists1("test"); // true
            bool result2_0 = Exists2("Test"); // true
            bool result2_1 = Exists2("test"); // true
            bool result3_0 = Exists3("Test"); // true
            bool result3_1 = Exists3("test"); // true
            bool result4_0 = Exists4("Test"); // true
            bool result4_1 = Exists4("test"); // true

            bool result5_0 = Exists1("Тест"); // true
            bool result5_1 = Exists1("тест"); // false
            bool result6_0 = Exists2("Тест"); // true
            bool result6_1 = Exists2("тест"); // false
            bool result7_0 = Exists3("Тест"); // true
            bool result7_1 = Exists3("тест"); // false
            bool result8_0 = Exists4("Тест"); // true
            bool result8_1 = Exists4("тест"); // false

            Console.WriteLine($@"result1_0 = {result1_0}
result1_1 = {result1_1}
result2_0 = {result2_0}
result2_1 = {result2_1}
result3_0 = {result3_0}
result3_1 = {result3_1}
result4_0 = {result4_0}
result4_1 = {result4_1}
result5_0 = {result5_0}
result5_1 = {result5_1}
result6_0 = {result6_0}
result6_1 = {result6_1}
result7_0 = {result7_0}
result7_1 = {result7_1}
result8_0 = {result8_0}
result8_1 = {result8_1}
");


        }

So i'm cannot create normal search for multiple languages, in console application this working normal (all results equals true)

@mkArtakMSFT mkArtakMSFT added area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly labels Aug 2, 2020
@GrabYourPitchforks
Copy link
Member

@tarekgh Do you know if wasm forces invariant globalization mode? That would force all case-insensitive comparisons to be ASCII only.

Related: dotnet/runtime#38126

@tarekgh
Copy link
Member

tarekgh commented Aug 2, 2020

Do you know if wasm forces invariant globalization mode? That would force all case-insensitive comparisons to be ASCII only.

WASM turned on using tailored package of ICU :-) so I believe they will have a better coverage. They will have the option to turn on Invariant Mode if anyone needed it.

@mkArtakMSFT
Copy link
Member

Thanks for contacting us.
This is going to be addressed in preview 8 release.

@ghost ghost locked as resolved and limited conversation to collaborators Sep 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly
Projects
None yet
Development

No branches or pull requests

4 participants