Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StringComparison, why "TH" not start with "T"

I am using StringComparison, "vi-VN" culture; Why does comparing string "TH" or "Th".StartsWith("T", StringComparison.CurrentCulture) return false?

like image 937
kien pham Avatar asked Mar 11 '23 09:03

kien pham


1 Answers

Th is a grapheme in Vietnamese. It is a single unit of text, rather than two units of text as it would be in English. Thus, Th does not start with T, as it is it's own unique character.

You would need to use a culture which does distinguish between Th and the letters T and h. For example:

"Th".StartsWith("T", StringComparison.InvariantCulture)
like image 192
Rob Avatar answered Mar 19 '23 03:03

Rob