2 ms·
Yes, it will explode if you try to write a Unicode string to something that doesn't have UTF-8 encoding by default. But it won't explode if you write byte strin
by mark-r 10y ago
Yes, it will explode if you try to write a Unicode string to something that doesn't have UTF-8 encoding by default. But it won't explode if you write byte strings, or if your default encoding is UTF-8.
- vetinari 10y agoWindows console is that case which doesn't default to UTF-8. At the time when I was working with it, py2 defaulted to ascii. For some locales Windows has additional bonus, the Ansi (GUI) encoding is different than OEM (console) and it was heroic undertaking to make your program work correctly for both. Python3 works out of the box.
- mark-r 10y agoI can sympathize, Windows is my environment too. But I'm not blind to other environments where some simplifying assumptions can be made. For true insanity try adding IDLE to the mix. IDLE under Windows in Python 2 will let you output UTF-8, but won't accept it as input. Python 3 is more consistent.