Alex Rivera | Logout

Converting the caps in an NSString into lowercase

Asked 2009-11-20T06:51:05.823
46

I have a issue while doing some encoding with the string. It returns all the values in CAPS. I want it to be small. Is there any api available in objective C to convert the caps in the NSString into small alphabet?

Edit
Report

1 Answer

4

If you want to use a specific locale (the NSString docs don't seem to indicate what locale the upper/lowercase/capitalise methods use) then you need to use a CFString function:

NSString* inputString = @"input";
NSString* outputString;
NSLocale* locale = [[NSLocale alloc] initWithLocaleIdentifier:@"tr_TR"];

CFMutableStringRef tempCFMString = CFStringCreateMutableCopy(NULL, 0, (CFStringRef)inputString);
CFStringCapitalize(tempCFMString, (CFLocaleRef)locale);
outputString = [[(NSString*)tempCFMString copy] autorelease];
CFRelease(tempCFMString);

//remember to release stuff
answered 2011-07-12T13:42:38.760

Your Answer