How do I print unicode with 5 characters

Viewed 192

I'm trying to make a discord bot in python and use Unicode for emojis using "\u", for example:

await ctx.send("\u1F389")

This should be the confetti popper emoji, but I've noticed it has 5 characters instead of the usual 4 (1F389) and clearly, Python did too, it prints Ἰ9, how can I fix this?

2 Answers

\u must be a 4-digit code. \U uses 8-digit codes:

>>> print('\U0001F389')

You can also use chr:

>>> print(chr(0x1f389))

Or look up and use by name:

>>> import unicodedata as ud
>>> ud.name(chr(0x1f389))
'PARTY POPPER'
>>> print('\N{PARTY POPPER}')

The Python notation for non-BMP Unicode code points uses \U instead of \u and eight hex digits.

await ctx.send("\U0001F389")
Related