I have strings from a JSON source that contains emojis and I can't upload these strings properly to my MySQL db because of this reason.
Fortunately I don't really need to save the exact string, so I can use unidecode(mystring)
which solves my problem, however I can't recognize which strings should be handled differently.
So my question is that how could I detect the strings with emojis in an if statement and unidecode the ones with emojis?
The best solution would be if I could do something like this:
if emoji in base_string:
new_string = unidecode(base_string)
else:
new_string = base_string
So far I have tried these solutions without any success:
if "xF0" in base_string:
new_string = unidecode(base_string)
else:
new_string = base_string
if "U000" in base_string:
new_string = unidecode(base_string)
else:
new_string = base_string
After reading about the topic I could log the strings with base_string.encode('utf-8')
but I still can't figure out how could I check for byte/str matching so I would really aprreciate if somebody could show me the right way.