Created
February 7, 2017 09:43
-
-
Save zhaorui/fd2fbb988b82981bdf7c8e6e550b6c08 to your computer and use it in GitHub Desktop.
See characters in CharacterSet (swift)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension CharacterSet { | |
var characters:[UnicodeScalar] { | |
var chars = [UnicodeScalar]() | |
for plane:UInt8 in 0...16 { | |
if self.hasMember(inPlane: plane) { | |
let p0 = UInt32(plane) << 16 | |
let p1 = (UInt32(plane) + 1) << 16 | |
for c:UInt32 in p0..<p1 { | |
if let us = UnicodeScalar(c) { | |
if self.contains(us) { | |
chars.append(us) | |
} | |
} | |
} | |
} | |
} | |
return chars | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment