strange behaviour of hasPrefix
strange behaviour of hasPrefix
- Subject: strange behaviour of hasPrefix
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Wed, 3 May 2017 22:25:07 +0700
// strange behaviour for probably all combining marks (macOS 12.4):
NSString *pintu = @"-ฺ"; // HYPHEN-MINUS + THAI CHARACTER PHINTHU
// ok
NSString *test1 = pintu;
[ self printTestString: test1 ];
// prints: length 2 0x2d 0xe3a “-ฺ” ok: has prefix “-“ __NSCFConstantString ← __NSCFString
// BAD
NSString *test2 = [ @"/some/path" stringByAppendingPathComponent: pintu ].lastPathComponent;
[ self printTestString: test2 ];
// prints: length 2 0x2d 0xe3a “-ฺ” BAD: has no prefix "-" NSPathStore2 ← NSString
- (void)printTestString: (NSString *)testWord
{
BOOL hasPre = [ testWord hasPrefix: @"-" ];
NSLog(@"%s length %tu %#x %#x \"%@\" %s prefix \"-\" %@ ← %@",__FUNCTION__,
testWord.length, [testWord characterAtIndex: 0], [testWord characterAtIndex: 1], testWord,
hasPre ? "ok: has" : "BAD: has no",
[testWord class], [testWord superclass] );
}
Why has test2 no prefix?
What am I doing wrong?
Gerriet.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden