i am trying to save strings that contain emojies to a .txt file, but I always get an error when running the code.
Code:
I set the .txt file up to have an utf-8 encoding.
subject_proper = subject.text.strip()
subject_proper = subject_proper.decode('utf-8')
Error:
subject_proper = subject_proper.decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'
Edit:
if i drop the .decode I get the following error:
UnicodeEncodeError: 'UCS-2' codec can't encode characters in position 65-65: Non-BMP character not supported in Tk
Edit 2:
Example text: Christmas treats for the triathletes ⛄
I have scraped the strings from https://milled.com/wiggle-co-uk
This method has worked before, but I dont know why it does not with this code. I have tried to find the answer elsewhere, but unfortunately without success.
I hope someone has an idea :)