I am trying to print some text with emojis from this form text = "\\ud83d\\ude04\\n\\u3082\\u3042"
, into:
# my expecting output
# a new line after the emoji, then is Japanese character
>>>
もあ
I have read a question about this, but just solve part of the problem:
Best and clean way to Encode Emojis (Python) from text file
I followed the code mentioned in the post, and I got below result:
emoji_text = "\\ud83d\\ude04\\n\\u3082\\u3042".encode("latin_1")
output = (emoji_text
.decode("raw_unicode_escape")
.encode('utf-16', 'surrogatepass')
.decode('utf-16')
)
print(output)
>>>\nもあ
# it prints \n instead of a new line
Therefore, I would like to ask, how can I convert the escape sequences \n, \t, \b etc. while converting the emoji and text?