First of all, your code is incorrect. characterAtIndex returns unichar , so you should use @"%C" (uppercase) as the format specifier.
Even with the correct format specifier, your code is unsafe and, strictly speaking, still incorrect, since not all Unicode characters can be represented by one unichar . You should always process unicode strings for each substring:
It is generally accepted to consider a string as a sequence of characters, but when working with NSString objects or using Unicode strings in general, in most cases it is better to deal with substrings, rather than individual characters. The reason for this is that the user is perceived as a character in the text, in many cases several characters per line can be represented.
You must read the String Programming Guide .
Finally, the correct code for you:
NSString *danishString = @"æøå"; NSMutableArray *characters = [[NSMutableArray alloc] initWithCapacity:[danishString length]]; [danishString enumerateSubstringsInRange:NSMakeRange(0, danishString.length) options:NSStringEnumerationByComposedCharacterSequences usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) { [characters addObject:substring]; }];
If with NSLog(@"%@", characters); you see a "strange character" of the form "\ Uxxxx", that's right. This behavior is the default string of the NSArray method on description . You can print these Unicode characters one by one if you want to see "regular characters":
for (NSString *c in characters) { NSLog(@"%@", c); }
source share