• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
strange behaviour of hasPrefix
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: strange behaviour of hasPrefix
      • From: Andy Lee <email@hidden>
    • Re: strange behaviour of hasPrefix
      • From: Ben Kennedy <email@hidden>
  • Prev by Date: NSDocument autosavesInPlace and additional menu items
  • Next by Date: Reconnecting to a NetService after a stream error
  • Previous by thread: Re: NSDocument autosavesInPlace and additional menu items
  • Next by thread: Re: strange behaviour of hasPrefix
  • Index(es):
    • Date
    • Thread