2016-12-27 116 views
0

有沒有一種方法可以在Sails REST API上使用emojis?我有我的表與utf8mb4_unicode_ci和手動我可以正確地存儲emojis。但在Web視圖和API響應上,它顯示爲一個問號「?」。Sails.js/Nodejs/Json支持emojis

請。歡迎您提供任何提示。

謝謝

更多信息:

比如我打的API與此

{ 
    "name": "hello", 
    "body": "Testing on node v6.9 x4", 
    "label": "info", 
    "user": 1 
} 

但響應:

{ 
    "name": "hello", 
    "body": "Testing on node v6.9 ???? x4", 
    "label": "info", 
    "thanks": 0, 
    "notUseful": 0, 
    "createdAt": "2016-12-28T15:30:26.000Z", 
    "updatedAt": "2016-12-28T15:30:26.000Z", 
    "id": 105, 
    "user": 1, 
    "topic": null 
} 
+0

您可以向我們展示API響應,以及如何獲取它? –

+0

做到了。請問,你有什麼想法。或者你是否知道在休息API中使用表情符號的正確方法? –

+0

對不起,我試圖改變「做」爲「完成」,但我得到這個錯誤http://meta.stackoverflow.com/questions/339725/users-without-the-comment-privilege-unable-to -edit-their-own-comments –

回答

3

你有沒有加入charsetcollation設置到您的MySQL配置config/connections.jsconfig/local.js

someMysqlServer: { 
    adapter: 'sails-mysql', 
    // other settings... 
    charset: 'utf8mb4', 
    collation: 'utf8mb4_unicode_ci', 
} 
+0

我愛你。真的真的非常感謝你.. –

+0

這工作完美。 –