Posts

Showing posts with the label emoji

Converting Java escape characters & emojis in a sentence with Python

Image
Clash Royale CLAN TAG #URR8PPP Converting Java escape characters & emojis in a sentence with Python For example, if I was given the following string: temp = "That looks great ud83dudc4c Good Job!" How can I convert it so that it either shows the actual emoji (👌) or the textual meaning (OK HAND SIGN)? Final result should like: temp = "That looks great 👌 Good Job!" or temp = "That looks great :OK HAND SIGN: Good Job!" I have tried using the emoji library in Python but it appears to only support Python escape characters. Is there any way to convert Java escape characters to Python escape characters? Thanks in advance! 1 Answer 1 No need for external libraries, use the built-in str function str.decode() str print temp.decode('unicode-escape') or tell python that your string contains unicode characters by making it a string literal prepending it with u'...