What’s the output of this c# code? Is the result always the same?
string s = "I";
Console.WriteLine(s.ToLower());
It outputs letter “I” in lower case.
i
But not always. Switch your Windows user’s regional settings to Turkish and the same code will output this:
ı
It’s a lower-case “i” without the dot. The Turkish language has two kinds of “i”, one with the dot, one without. The small “i” has an upper-case pendant, too:
İ
You might think if that has anything to do with SwyxWare? It has. Last week I got a question from one of my pre-sales support colleagues. A customer observed that SwyxIt! would not login when the Windows user has Turkish regional settings. Today I finally got trace files from SwyxIt! and could narrow down the location of the failure. There is a condition in SwyxIt! similar to this:
if (s.ToLower().StartsWith("i"))Unfortunately the string checked in this statement starts with an upper-case “I”. The expression returns false for Turkish regional settings and true if you use English or German or almost any other language setting. In this case the fix is easy:
if (s.ToLower(CultureInfo.InvariantCulture).StartsWith("i"))Using InvariantCulture is correct in this case, but other scenarios might needs a different approach.