> On Apr 3, 2015, at 11:04 AM, Quincey Morris
> <[email protected]> wrote:
>
> On Apr 3, 2015, at 04:00 , Charles Jenkins <[email protected]> wrote:
>>
>> for char in String( self ).utf16 {
>> if set.characterIsMember( char ) {
>> return true
>> }
>
> Now we’re back to the place we started. This code is wrong. It fails for any
> code point that isn’t representable a single UTF-16 code value, and it fails
> for any grapheme that isn’t representable as a single code point.
No it doesn't. Give it a test.
let acuteA: Character = "\u{e1}" // An "a" with an accent
let acuteAComposed: Character = "\u{61}\u{301}" // Also an "a" with an accent
func howManyChars( c: Character) -> Int {
var count = 0
for char in String( c ).utf16 {
count += 1
}
return count
}
howManyChars(acuteA) // returns 1
howManyChars(acuteAComposed) // returns 2
The original code will return true only if all code points map to white space.
Marc
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]