Swift Encode/decode emojis
Your encoding code can be simplified to func encode(_ s: String) -> String { let data = s.data(using: .nonLossyASCII, allowLossyConversion: true)! return String(data: data, encoding: .utf8)! } Note that it encodes all non-ASCII characters not only Emojis (as \uNNNN where NNNN is the hexadecimal code of the Unicode character, or as \NNN where NNN is … Read more