I need to change Python's encoding from cp1252 to UTF-8. Using python 3.7.1, Atom, and Atom script package for terminal.
I have read about https://www.python.org/dev/peps/pep-0540/ (a solution to this? I dont know how to implement or if useful) I cannot find a sound resolution.
Currently it cannot handle '\u2705' or others. When checking the Python file directory I found ...Python\Python37\lib\encodings\cp1252.py
#When I run
import locale
import sys
print(sys.getdefaultencoding())
print(locale.getpreferredencoding())
#I get
utf-8
cp1252
[Finished in 0.385s]
#Error for print('\u2705')
Traceback (most recent call last):
File "C:\Users\en4ijjp\Desktop\junk.py", line 7, in <module>
print('\u2705').decode('utf-8')
File "C:\Users\en4ijjp\AppData\Local\Programs\Python\Python37\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2705' in
position 0: character maps to <undefined>
[Finished in 0.379s]
I expect my terminal to handle the characters and display them when using print()