I\'ve never fully wrapped my head around encoding and decoding unicode to other formats (utf-8, utf-16, ascii, etc.) but I\'ve reached a wall thatis both confusing and frust
You can look at it this way. A string is a sequence of characters, not a sequence of bytes. Characters are Unicode codepoints. Bytes are just numbers in range 0–255. At the low level, computers work just with sequences of bytes. If you want to a print a string, you just call print(a_string) in Python. But to communicate with the OS environment, the string has to be encoded to a sequence of bytes. This is done automatically somewhere under the hoods of print function. The encoding used is sys.stdout.encoding. If you get an UnicodeEncodeError, it means that your characters cannot be encoded using the current encoding.
As far as I know, it is currently not possible to run Python on Windows in a way that that the encoding used is capable of encoding every character (as UTF-8 or UTF-16) and both assumed by Python and really used by the OS environment for both input and output. There is a workaround – you can use win_unicode_console package, which aims to solve this issue. Just install it by pip install win_unicode_console, and in your sitecustomize import it and call win_unicode_console.enable(). This will serve as an external patch to your Python installation ragarding this issue. See the documentation for more information: https://github.com/Drekin/win-unicode-console.