I'm using request module in order to send message to a Telegram bot, everything is fine, except the way I'm display emojis, which don't get printed well
Post request:
request.post({
url: `${this.getApiURL()}/${apiName}`,
formData: payload,
headers: {
'Content-Type': 'application/json',
'Charset': 'utf-8',
}
}, (err, resp, body) => {});
The payload contains a text message with some emojis like:
const _emojis = {
throwingAKiss: '\xF0\x9F\x98\x98',
tearsOfJoy: '\xF0\x9F\x98\x82',
smirkingFace: '\xF0\x9F\x98\x8F'
}
but I'm displaying this symbol ð
I'm using request module in order to send message to a Telegram bot, everything is fine, except the way I'm display emojis, which don't get printed well
Post request:
request.post({
url: `${this.getApiURL()}/${apiName}`,
formData: payload,
headers: {
'Content-Type': 'application/json',
'Charset': 'utf-8',
}
}, (err, resp, body) => {});
The payload contains a text message with some emojis like:
const _emojis = {
throwingAKiss: '\xF0\x9F\x98\x98',
tearsOfJoy: '\xF0\x9F\x98\x82',
smirkingFace: '\xF0\x9F\x98\x8F'
}
but I'm displaying this symbol ð
Share Improve this question edited May 16, 2018 at 8:28 Donovant asked May 15, 2018 at 23:58 DonovantDonovant 3,1618 gold badges45 silver badges75 bronze badges 5-
It seems like only your first group is used, as ð is
U+00F0
in UTF8. – k0pernikus Commented May 16, 2018 at 9:33 -
1
Can you try using this syntax:
"\u{1F604}"
? ( apps.timwhitlock.info/emoji/tables/unicode ) – k0pernikus Commented May 16, 2018 at 9:36 - Also you could try: github./omnidan/node-emoji – k0pernikus Commented May 16, 2018 at 9:41
- It worked, thanks. It's weird because my code above used to work couple of days ago -_- – Donovant Commented May 16, 2018 at 9:47
- I have added my ment as an answer after your feedback. – k0pernikus Commented May 16, 2018 at 12:07
1 Answer
Reset to default 5As a workaround you may have success with using a different unicode notation, i.e.:
const smiley = "\u{1F604}";
For a list of codes, there are emoji tables out there.
Additionally, it might ease a bit development overhead by using libraries such as node-emoji (which uses raw emojis under the hood through omnidan/node-emoji json file.