I've written a Python3 script to extract strings of C/C++/Java source codepoints/surrogate pairs for emoji characters (\ud83d\ude00
for , for example) from a text file.
I also have a dictionary in this script mapping emoji to their descriptions ("" => "grinning face"). How can I convert the surrogate pairs (\ud83d\ude00
, string literal) to their emoji counterparts in order to use them as keys to access the corresponding emojis' descriptions in the dictionary?
For some additional information, I'm extracting the strings in such a way that when I run print(extracted_string)
, the console output is \ud83d\ude00
. When I attempt to assign the value at the emoji key to a variable, I get back an error:
description = dictionary[extracted_string]
KeyError: '\\ud83d\\ude00'