Swift: 将16进制emoji表情, 转成具体字符

  • 将emoji表情的16进制字符串, 转成具体的表情文字
let code = "0x1f603"
let scanner = Scanner(string: code)
var result: UInt32 = 0
scanner.scanHexInt32(&result)
guard let us = UnicodeScalar(result) else {
    return
}
let character = Character(us)
let emoji = String(character)
print(emoji)    
// 打印: 

你可能感兴趣的:(Swift: 将16进制emoji表情, 转成具体字符)