StringComparison not working in Linux (Kubernates) environment

asked 2022-11-23T09:17:50.327+00:00
Elaya Raja 96 Reputation points

Hi Team,

The following comparison gets different results in windows env and Linux env.

string sb = "EÖALE";
string ss = "EöALE";
CultureInfo`.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
StringComparer sc1 = StringComparer.Create(CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace);
log($"Compare :{sc1.Compare(sb, ss)} \n");// OutPut 108
string s1 = "EÖALE";
string s2 = "EöALE";
bool currentCultureIgnoreCaseEquality = string.Equals(s1, s2, StringComparison.CurrentCultureIgnoreCase);
//OutPut false in linux

bool equality = string.Equals(s1, s2); //OutPut false in linux
bool ordinalIgnoreCaseEquality = string.Equals(s1, s2, StringComparison.OrdinalIgnoreCase);//OutPut false in linux
bool InvariantCultureIgnore = string.Equals(s1, s2, StringComparison.InvariantCultureIgnoreCase);//OutPut false in linux

How to achieve to get true this comparison in Linux environment
I am using Dotnet core
Thanks in Advance

.NET Standard
.NET Standard
A formal specification of .NET APIs that are available on multiple .NET implementations.
482 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,922 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: The period of time during which a program is being executed in a computer.
953 questions
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2022-11-28T05:34:26.98+00:00
    Elaya Raja 96 Reputation points

    I found the solution here. It seems this issue was resolved in .net 6, and the other below versions have this issue.

    No comments