• 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
Re: Where is my bicycle?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where is my bicycle?


  • Subject: Re: Where is my bicycle?
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Tue, 07 Apr 2015 16:21:08 +0700

> On 7 Apr 2015, at 00:15, Quincey Morris <email@hidden> wrote:
>
> On Apr 6, 2015, at 09:19 , Gerriet M. Denkmann <email@hidden> wrote:
>
> A suggestion, though:
>
> Try building your character set using ‘characterSetWithRange:’ and/or the NSMutableCharacterSet methods that add ranges, instead of using NSStrings. Maybe NSCharacterSet really is UTF-32-based, but not — for code compatibility reasons — when using NSStrings explicitly.

This turned out to be an excellent idea - it allowed me to create a replacement for characterSetWithCharactersInString: which actually works:

//	bug work-around
+ (NSCharacterSet *)gmdCharacterSetWithCharactersInString: (NSString *)string
{
	if ( string.length == 0 )	//	return nil
	{
		NSLog(@"%s string \"%@\" is empty or nil → no CharacterSet.",__FUNCTION__, string);
		return nil;
	};

	NSData *dat = [ string dataUsingEncoding: NSUTF32StringEncoding ];
	const UTF32Char *bytes = dat.bytes;
	NSUInteger length = dat.length / sizeof(UTF32Char);

	NSMutableCharacterSet *mus = [ [ NSMutableCharacterSet alloc ] init ];
	for( NSUInteger i = 1; i < length; i++ )	//	ignore initial kUnicodeByteOrderMark
	{
		UTF32Char codePoint = bytes[i];
		[ mus addCharactersInRange: NSMakeRange( codePoint, 1 ) ];
	};

	return mus;
}

Thanks very much for your suggestion!


Kind regards,

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: Where is my bicycle?
      • From: Quincey Morris <email@hidden>
References: 
 >Where is my bicycle? (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: Where is my bicycle? (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Where is my bicycle?
  • Next by Date: Re: Navigationbar doesn't work in iOS 7.1 / 8 with XCODE 6.2
  • Previous by thread: Re: Where is my bicycle?
  • Next by thread: Re: Where is my bicycle?
  • Index(es):
    • Date
    • Thread