Re: How to enumerate by code points in Swift beta4?
Re: How to enumerate by code points in Swift beta4?
- Subject: Re: How to enumerate by code points in Swift beta4?
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Wed, 23 Jul 2014 16:48:42 +0700
On 23 Jul 2014, at 16:19, Roland King <email@hidden> wrote:
>
>> On 23 Jul 2014, at 5:03 pm, Quincey Morris <email@hidden> wrote:
>>
>> On Jul 22, 2014, at 23:26 , Roland King <email@hidden> wrote:
>>
>>>
>
> Well again the wonderful swift book gives us string.unicodeScalars, which instead of failing to define myself I’ll just copy from the book.
>
> “This property is of type UnicodeScalarView, which is a collection of values of type UnicodeScalar. A Unicode scalar is any 21-bit Unicode code point that is not a lead surrogate or trail surrogate code point.
This works perfectly:
let ss = "Hello \u{1F30D}"
println("string \"\(ss)\" in UnicodeScalars:")
for (i,s) in enumerate(ss.unicodeScalars)
{
let out1 = NSString(format: "codePoint[%2lu]", i )
let out2 = NSString(format: "%#7x", UInt32(s) )
let out3 = "\"" + String(s) + "\""
println("\(out1) = \(out2) = \(out3)")
}
Thanks a lot for your help!
Kind regards,
Gerriet.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden