On 2 Oct 2016, at 19:02, Jean-Denis Muys via swift-users 
<swift-users@swift.org> wrote:

> The problem is, I could not find a simple way to convert from a character to 
> a unicodeScalar. 

As is often the case with string examples, it would help if you posted more 
about your context.  With the details we have now your code could be written 
like this:

let vowels = CharacterSet(charactersIn: "AEIOU")
let char: UnicodeScalar = "E"
vowels.contains(char)

but I’m pretty sure that won’t help in your real app (-:  So, my questions:

* Do you plan to use a fixed character set?  Or is the character set itself 
built at runtime?

* Do you have specific knowledge of either of the inputs?  Like that they’re 
all ASCII?  Or normalised in a certain way?

* Specifically, where do the characters you’re trying to test (`char` in your 
example) come from?  Do they represent user input, in which case they can be 
arbitrary Unicode?  Or something more constrained

Share and Enjoy
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware


_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to