Print unicode character from variable (swift)

前端 未结 6 450
耶瑟儿~
耶瑟儿~ 2020-11-30 14:53

I have a problem I couldn\'t find a solution to. I have a string variable holding the unicode \"1f44d\" and I want to convert it to a unicode character

6条回答
  •  醉酒成梦
    2020-11-30 15:29

    You can use

    let char = "-12"
    print(char.unicodeScalars.map {$0.value }))
    

    You'll get the values as:

    [45, 49, 50]
    

提交回复
热议问题