Error with Unicodes on Discord Embed

Hi there, I am having an issue where I am trying to add the Bullet character into one of my embeds.

I am using the following code to insert in the character:


The character gets turned into this weird unicode instead of what I wanted:

I would like to know why this happens and how I would resolve it.

Which of these characters is correct?

The correct character should be this bullet: “

EDIT: use utf8.char("8226"). It appears just using the HTML entity (in decimal notation) works.


Post before my edit:

You’re using a library named "utf8" which likely means you’re using utf-8 encoding. 0x2022 is the “bullet” representation in a utf-16 encoding.


Try using utf8.char("0xE2"), utf8.char("0x80"), or utf8.char("0xA2")

1 Like

Using utf8.char("0x2022") and utf8.char("8226") both work the same way. Try both and see if either works.

You’re right.

utf8.char("0x2022") didn’t work for OP so I assumed it would not work for me. Checking again and it does work…? Weird


I don’t see why 0x2022 would work in the first place-considering 0x2022 is the 16 bit-encoding representation meanwhile the library is named utf8.

Very interesting.
Wonder why utf8.char doesn’t accept the hex byte sequence.

I am still having the same issue regardless of what type of sequence I give to it.

Wrap it in a print function instead, and see what happens.

When I print the JSONEncoded result it shows the characters properly for some reason.

I have figured out how to fix this issue and I’m going to post how to fix it here for anyone else to check out if they run into the same issue.

If you send the webhook directly:

string.gsub(JSONEncoded Data, utf8.char("0xE2") .. utf8.char("0x80") .. utf8.char("0xA2"), utf8.char("0x2022"));

If you are sending the webhook via a Proxy or website:
You use what I gave above aswell as you change the Content-Type header to: “application/json; charset=utf-8”