Turkish "I" error in our test code

One of the lessons I learned when working on OneNote 2010 has to do with the Turkish alphabet (I do not speak Turkish).  In that language, the capital "I" character has a lowercase "i" which looks
like this:   ı

Notice how there is no dot above the i.

So if you call some code that automatically converts to lower case with a string with 'I' in it, the character on a Turkish locale machine will see an ı  character in that place instead.

There is a nice article with some code for this here which might be interesting reading.

The way this affected our tests was in our verifications.  When we try to load files during some of our tests, we just want to load the file and that's it.  The problems come in when files such as "Internal Registry File.reg" need to be imported.  Windows itself does not care about capitalization (canonicalization, in the lingo) so "Internal Registry File.reg" and "internal registry file.reg" and "InterNal REGISTry File.reG" are all the same.


Going back to the problem, if anyone modifies the file name by changing only the capitalization of letters - which should never happen, but sometimes does - I don't want our tests failing.  So our code typically has statements in it to convert strings of this type to all lower case letters:


string myFile = "c:\Internal Registry File.reg"

myFile = myFile.ToLower();

So now the file I am using is in this format  "internal registry file.reg" and the test passes.

But on Turkish builds, I would wind up with "ınternal registry file.reg" and would fail since "i" and" ı" are not the same character at all.

One of the testers
noticed this and made our test code more resilient by checking for Turkish language usage just as the article mentions (I'm not going to copy/paste that code here).

Now in the event someone does change the canonicalization of the file name, our test will still run on all languages.

Questions, comments, concerns and criticisms always welcome,

Comments (3)

  1. David says:

    Try this –     string myFile = "c:Internal Registry File.reg".ToString();

  2. Max B-H says:

    Why not use the ToLowerInvariant() method (it always returns the same tolower value no matter what locale is running)?


  3. John says:

    Max B-H : Good point.  We used ToLower(CultureInfo.InvariantCulture) which according to MSDN is equivalent.  

Skip to main content