BUG with NSString stringByTrimmingCharactersInSet
BUG with NSString stringByTrimmingCharactersInSet
- Subject: BUG with NSString stringByTrimmingCharactersInSet
- From: p3consulting <email@hidden>
- Date: Mon, 23 Jun 2003 13:55:25 +0200
Looks like stringByTrimmingCharactersInSet returns incorrect results
when input string is only 1 char or 1 char after trimming white space
in front.
NSLog(@"'A' trimmed '%@'",[@"A"
stringByTrimmingCharactersInSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]]) ;
NSLog(@"' A ' trimmed '%@'",[@" A "
stringByTrimmingCharactersInSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]]) ;
NSLog(@"' A' trimmed '%@'",[@" A"
stringByTrimmingCharactersInSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]]) ;
NSLog(@"'A ' trimmed '%@'",[@"A "
stringByTrimmingCharactersInSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]]) ;
'A' trimmed '' <-- should be 'A'
' A ' trimmed 'A'
' A' trimmed '' <-- should be 'A'
'A ' trimmed 'A'
OK if string length > 1:
NSLog(@"'AB' trimmed '%@'",[@"AB"
stringByTrimmingCharactersInSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]]) ;
NSLog(@"' AB ' trimmed '%@'",[@" AB "
stringByTrimmingCharactersInSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]]) ;
NSLog(@"' AB' trimmed '%@'",[@" AB"
stringByTrimmingCharactersInSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]]) ;
NSLog(@"'AB ' trimmed '%@'",[@"AB "
stringByTrimmingCharactersInSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]]) ;
'AB' trimmed 'AB'
' AB ' trimmed 'AB'
' AB' trimmed 'AB'
'AB ' trimmed 'AB'
Same bug with whitespaceCharacterSet, punctuationCharacterSet and
probably other CharacterSet as well but not tested.
Somebody knows if already in RADAR ?
Pascal Pochet
P3 Consulting
email@hidden
http://www.p3-consulting.net
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.