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: Quincey Morris <email@hidden>
- Date: Fri, 03 Apr 2015 18:38:03 +0000
On Apr 3, 2015, at 11:19 , Marco S Hyman <email@hidden> wrote:
>
> The original code will return true only if all code points map to white space.
The “failure” I was talking about is something a bit different. It has two problems:
1. For Unicode code points that are represented by 2 code values, it tests the code values, not the code points. That’s wrong.
2. For graphemes that are represented by 2 or more code points, it still tests the code values, of which there could be 4 or more per grapheme. That’s also wrong. With the ‘for char in String (self)’ code, if you tested whether a decomposed acuteA was in the (7-bit) ASCII character set, you’d get the answer “YES".
You could mitigate #1 by using UTF-32 code values instead of UTF-16, but that wouldn’t help with #2.
_______________________________________________
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