Tags: , , , , , | Categories: Genel Posted by okutbay on 08.10.2009 16:01 | Yorumlar (0)

According to business rule all footballer name and surname must be capitalized and not longer than 8 chars length.

Very simple to develop. We develop a wrapper method for this job. Seems working fine. Until this morning. Game masters of the http://icanfootball.com noticed that some player names violates this business rule. After my first debuging i found the problem. ToLowerInvariant method is the guilty. No, infact the developer who uses this method is guilty. Because this methods unable to convert "i" to "İ", "ı" to "I" or reverse. This chars specific to Turkish locale and this methods are invariant (means Culture Indepentend and works same as calling ToLower or ToUpper method with CultureInfo.InvariantCulture enum). 

So in my opinion this methods are useless. Please use ToLower or ToUpper method with appropriate culture info.

You can check this sample code.

 

    1 string a = "ı I ş Ş ç Ç ğ Ğ ö Ö ü Ü i İ";

    2 

    3 string b = a.ToLowerInvariant();//b = "ı i ş ş ç ç ğ ğ ö ö ü ü i İ" fails to convert

    4 string d = a.ToUpperInvariant();//c = "ı I Ş Ş Ç Ç Ğ Ğ Ö Ö Ü Ü I İ" fails to convert

    5 

    6 string culture = "tr-TR";

    7 System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo(culture);

    8 

    9 string c = a.ToLower(cultureInfo);//d = "ı ı ş ş ç ç ğ ğ ö ö ü ü i i"

   10 string e = a.ToUpper(cultureInfo);//e = "I I Ş Ş Ç Ç Ğ Ğ Ö Ö Ü Ü İ İ"

 

 

Bu yazıyı ilk değerlendiren siz olun

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Yorumlar

Yorum ekle


(Gravatar simgesini gösterecek)  

  Country flag

biuquote
  • Yorum
  • Canlı önizleme
Loading