Re: Swift: How to determine if a Character represents whitespace?
Re: Swift: How to determine if a Character represents whitespace?
- Subject: Re: Swift: How to determine if a Character represents whitespace?
- From: Jens Alfke <email@hidden>
- Date: Thu, 02 Apr 2015 08:33:34 -0700
> On Apr 2, 2015, at 4:54 AM, Charles Jenkins <email@hidden> wrote:
>
> What would be nice is a way to count leading and trailing characters in place while the thing is still an NSAttributedString--without using NSAttributedString.string to convert to a Swift string in the first place. If there were no conversion to the unicode-compliant and amazingly difficult-to-do-anything-with-it Swift string, I’d be more confident that the shrunken range I calculate would be apples to apples.
Use NSString.rangeOfCharactersFromSet() on the attributed string’s underlying NSString.
Don’t use any native Swift String character accessors, because the character positions aren’t going to agree with NSString since they use different interpretations of Unicode.
—Jens
_______________________________________________
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