Answers
方法是先用这几个codeUnit做成NSData,然后再转成NSString,就能得到对应的字符串了。
import Foundation
var bytes:[Byte]=[240,159, 144, 182]
let data = NSData(bytes: bytes, length: bytes.count)
let dogString:String = NSString(data: data, encoding: NSUTF8StringEncoding)
顺便一提,1F436这个16进制数,也能直接通过UnicodeScalar转换成字符串,就像下面这样
var dogInt:UInt32=0x1F436
let dog:String=UnicodeScalar(dogInt).escape(asASCII: false)
DOG FACE
怎么这么天才
answered 10 years, 3 months ago