【问题标题】:Convert unicode to emoji将 unicode 转换为表情符号
【发布时间】:2014-09-09 13:47:50
【问题描述】:

我正在寻找一种表示表情符号的方法 ????在我的代码中作为 unicode,然后在输出文本中显示为实际的“图像”。我想使用http://apps.timwhitlock.info/unicode/inspect/hex/1F4C4 在应用程序中显示“页面朝上”,但我不喜欢在我的代码中包含图片的想法(尽管它工作正常);)

【问题讨论】:

    标签: swift emoji


    【解决方案1】:

    您可以直接在源代码中使用任意 Unicode 字符

    let string = "?"
    

    或使用 Swift Unicode 转义序列:

    let string = "\u{1F4C4}"
    

    更多信息请参见 Swift 参考中有关 "String Literals" 的部分。

    【讨论】:

    • 是的,我确实在我的代码中使用了表情符号本身,但正如我所说,我不喜欢在其中包含图像的想法。 Swift 转义序列运行良好,感谢您的回答!
    猜你喜欢
    • 2015-10-18
    • 2015-01-15
    • 2018-11-16
    • 1970-01-01
    • 1970-01-01
    • 2019-07-11
    • 2012-01-27
    • 2018-07-19
    • 2019-05-20
    相关资源
    最近更新 更多