• 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: How to enumerate by code points in Swift beta4?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >How to enumerate by code points in Swift beta4? (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: How to enumerate by code points in Swift beta4? (From: Roland King <email@hidden>)
 >Re: How to enumerate by code points in Swift beta4? (From: Quincey Morris <email@hidden>)
 >Re: How to enumerate by code points in Swift beta4? (From: Roland King <email@hidden>)

  • Prev by Date: Re: How to enumerate by code points in Swift beta4?
  • Next by Date: How to detect endian-ness in Swift?
  • Previous by thread: Re: How to enumerate by code points in Swift beta4?
  • Next by thread: How to detect endian-ness in Swift?
  • Index(es):
    • Date
    • Thread