rangeOfString behaves wierd
rangeOfString behaves wierd
- Subject: rangeOfString behaves wierd
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Mon, 09 Dec 2013 14:46:27 +0700
In 10.9.0, Xcode 5.0.2 I added these lines to applicationDidFinishLaunching:
NSString *a = @"见=見見"; // 0x89c1 0x3d 0xfa0a 0x898b
NSString *b = @"见≠見"; // 0x89c1 0x2260 0x898b
NSRange aRange = [ a rangeOfString: b ];
NSLog(@"%s \"%@\" (%lu shorts) occurs in \"%@\" (%lu shorts) at %@",__FUNCTION__,
b, [b length], a, [a length], NSStringFromRange(aRange));
And was told:
"见≠見" (3 shorts) occurs in "见=見見" (4 shorts) at {0, 4}
This comes somewhat unexpected.
What am I doing wrong?
Or are my expectations false?
I would (maybe naively) expect that the shorter string could at most occur at {0,3}.
I would also expect that ≠ is NOT quite the same as =.
But then, I was wrong before.
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