Turkish culture problem with ToUpper() for letter i

Recently, the support team reported a problem where our clients from Turkey not seeing any items on a particular page. The support team had logged in as those clients and confirmed that they could see those items on that page. This problem then got escalated to the technical team. After trying out different ways to reproduce the bug, we eventually found that this is caused by the browser culture being set to Turkish.

The code that retrieves this list of items calls a legacy service that gets items with status of ‘Active’ as below

This works fine but breaks when your culture is Turkish. The lowercase ‘i’ when converting to uppercase in Turkish will become İ (notice the dot on top). So status ‘active’ will become ‘ACTİVE’ which does not equal to ‘ACTIVE’ hence no items got returned.

It is very simple to fix this issue, you could either use ToUpperInvariant() which is culture insensitive

or use the Equals() with StringComparison.OrdinalIgnoreCase. This is my preferred way as you don’t need to convert the string to uppercase.

 

Like this post?

Leave a Reply

Your email address will not be published. Required fields are marked *