On 19 Oct 2010, at 00:54, Alex Kac <[email protected]> wrote:

>       NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
>       NSString* am = [[[formatter AMSymbol] substringToIndex:1] 
> lowercaseString];


Please note that substringToIndex does only sometimes return a valid string.

I just tried:

NSString *a = @"𝍢";     //      COUNTING ROD UNIT DIGIT THREE
NSLog(@"%s a \"%...@\"",__FUNCTION__, a);       //      ok

NSString *badString = [ a substringToIndex: 1 ];
NSLog(@"%s a \"%...@\" badString \"%...@\"",__FUNCTION__, a, badString);        
// ← this never shows
// because "badString" is not a valid string at all (I would have expected some 
log message though).

NSRange aRange = [ a rangeOfComposedCharacterSequenceAtIndex: 0 ];
NSString *goodString = [ a substringWithRange: aRange ];
NSLog(@"%s a \"%...@\" goodString \"%...@\"",__FUNCTION__, a, goodString);      
 
// this works ok and contains the first "character" in of string "a".

I admit that it is rather unlikely that this will be a problem with normal 
Korean text (but I know nothing about Korean scripts).


Kind regards,

Gerriet.

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to