Created
November 29, 2017 09:34
-
-
Save hassi32/5ebdfc7ab0d95af7680f5489f6fcba7f to your computer and use it in GitHub Desktop.
encode emoji in Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func encode(_ s: String) -> String { | |
let data = s.data(using: .nonLossyASCII, allowLossyConversion: true)! | |
return String(data: data, encoding: .utf8)! | |
} | |
let emoji = "👪" | |
encode(emoji) // \ud83d\udc6a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment