Home > DeveloperSection > Forums > CapitalizedString with Turkish letters
Allen Scott

Total Post:41

Points:289
Posted on    October-28-2014 2:26 AM

 iPhone iPhone  Ios  Ios 4 
Ratings:


 1 Reply(s)
 769  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. newsCategory.name contains 'ASKERİ HAVACILIK' which is NSString.

 +(NewsCategory*) convertCategory: (NSMutableDictionary *) jsonDictionary{
        NewsCategory *newsCategory = [[NewsCategory alloc] init];
        newsCategory.name =[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"];
newsCategory.name =  [capitalizedName capitalizedString];
But unfortunately, it shows @"Askeri̇ Havacilik"
How I convert this to 'Askeri Havacılık' ?


Maria Susan

Total Post:29

Points:107
Posted on    October-28-2014 2:28 AM

NSString *capitalizedName = [jsonDictionary objectForKey:@"name"];

NSString *accentedString = capitalizedName;
NSString * capitalizedString = [accentedString stringByFoldingWithOptions:NSDiacriticInsensitiveSearch locale:[NSLocale currentLocale]];
newsCategory.name =  [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.

Don't want to miss updates? Please click the below button!

Follow MindStick