For example, we have:
var char:Character="\u{1F496}" //get a Character like a heart
How to do the opposite work, like how to get Character ("A")'s unicode.
For example, we have:
var char:Character="\u{1F496}" //get a Character like a heart
How to do the opposite work, like how to get Character ("A")'s unicode.
Can do something like that:
let char: Character = "\u{1F496}"
let value: Int = Int(NSString(string: String(chat)).characterAtIndex(0))
Character
does not represent a single Unicode code point, but rather a "Unicode grapheme cluster". To represent a single Unicode code point, you want UnicodeScalar
.
let char: UnicodeScalar = "\u{1F496}"
println(char.value) // prints "128150"