How does Facebook encode emoji in the json Graph API?

后端 未结 1 588
北恋
北恋 2021-01-14 10:06

Does anyone know how Facebook encodes emoji with high-surrogate pairs in the Graph API?

Low surrogate pairs seem fine. For example, ❤️ (HEAVY BLACK HEART, though it

相关标签:
1条回答
  • 2021-01-14 11:03

    Answering my own question though most of the credit belongs to @bobince for showing me the way in the comments above.

    The answer is that Facebook encodes emoji using the "Google" encoding as seen on this Unicode table.

    I have created a ruby gem called emojivert that can convert from one encoding to another, including from "Google" to "Unified". It is based on another existing project called rails-emoji.

    So the failing example above would be fixed by doing:

    string = ActiveSupport::JSON.decode('"\udbba\udf59"')
    > "                                                                    
    0 讨论(0)
提交回复
热议问题