String.Equals GID returning false?

Viewed 1079

I have the following C# code in my ASP.NET MVC application. I try to compare 2 string using the Equals method, with culture = "vi". My code below:

string culture = "vi";

System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);
System.Threading.Thread.CurrentThread.CurrentUICulture = 
  System.Threading.Thread.CurrentThread.CurrentCulture;

var CCC = string.Equals("CategId", "CATEGID", StringComparison.CurrentCultureIgnoreCase);
var xx = string.Equals("TestGID", "TestGID", StringComparison.CurrentCultureIgnoreCase);
var zz = string.Equals("id", "ID", StringComparison.CurrentCultureIgnoreCase);

Results:

CCC = false;

xx = true;

zz = true;

I don't know why CCC is false. Is there anything wrong? If I set culture = id, ko, en, etc... then CCC = true. Who can help me?

2 Answers

It is gI which is not equal to GI in case of Vietnamese language. gi (GI) is syllable-initial, kind of one letter while gI are two separate letters. Other pairs are

cH != CH
kH != KH
nG != NG
nH != NH
pH != PH
qU != QU
tH != TH
tR != TR

https://en.wikipedia.org/wiki/Vietnamese_language

You can try

string culture = "vi";

System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);

System.Threading.Thread.CurrentThread.CurrentUICulture = 
  System.Threading.Thread.CurrentThread.CurrentCulture;

var CCC = string.Equals("CategId", "CATEGID", StringComparison.InvariantCultureIgnoreCase);
var CCC1 = string.Equals("CategId", "CATEGID", StringComparison.CurrentCultureIgnoreCase);

In this CCC will return true but CCC1 will return false because of Culture. as per your Culture GID and gId is different.

Related