我正在寻找一种方法来在我的代码中将表情符号 📄 表示为 unicode,然后在输出文本中显示为实际的“图像”。我想使用 http://apps.timwhitlock.info/unicode/inspect/hex/1F4C4在应用程序中显示“页面朝上”,但我不喜欢在我的代码中包含图片的想法(尽管它工作正常);)
最佳答案
您可以直接在源代码中使用任意 Unicode 字符
let string = "📄"
或者使用 Swift Unicode 转义序列:
let string = "\u{1F4C4}"
有关 "String Literals" 部分的更多信息在 Swift 引用中。
关于swift - 将 unicode 转换为表情符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25746339/