CapitalizedString with Turkish letters

Total Post:46

iPhone  Ios  Ios 4 
 1280  View(s)
Rate this:
I have a problem with Turkish letters.

I have a method for deserialize the JSON. I'm getting the correct data from web service and I set it to my object's variable. contains 'ASKERİ HAVACILIK' which is NSString.

 +(NewsCategory*) convertCategory: (NSMutableDictionary *) jsonDictionary{
        NewsCategory *newsCategory = [[NewsCategory alloc] init]; =[jsonDictionary objectForKey:@"name"];
        return newsCategory;
I have to convert 'ASKERİ HAVACILIK' to 'Askeri Havacılık'. So I used capitalizedString for this.

NSString *capitalizedName = [jsonDictionary objectForKey:@"name"]; =  [capitalizedName capitalizedString];
But unfortunately, it shows @"Askeri̇ Havacilik"
How I convert this to 'Askeri Havacılık' ?
  1. Post:29

    Re: CapitalizedString with Turkish letters

    NSString *capitalizedName = [jsonDictionary objectForKey:@"name"];
    NSString *accentedString = capitalizedName;
    NSString * capitalizedString = [accentedString stringByFoldingWithOptions:NSDiacriticInsensitiveSearch locale:[NSLocale currentLocale]]; =  [capitalizedString capitalizedString];
    Depending on the nature of the strings you want to convert, you might want to set a fixed locale (e.g. English) instead of using the user's current locale. That way, you can be sure to get the same results on every machine.

      Modified On Apr-06-2018 01:21:47 AM



Enter your email address here always to be updated. We promise not to spam!