5 ms·
They main problem with Python encoding is the cmd.exe on Windows does not support certain >127 ASCII, thus Ordinal >127 error is pretty common python encoding e
by est 16y ago
They main problem with Python encoding is the cmd.exe on Windows does not support certain >127 ASCII, thus Ordinal >127 error is pretty common python encoding error. But Python could handle >127 ASCII well internally. The real devil in the python encoding myth is the `print` function.
BTW using `mbcs` encoding on Windows is more compatible than ASCII in most cases.
- piranha 16y agoHm, strange, I have no problems using cp866 to print something to console on Windows.
- adamtj 16y agoThere are no ASCII characters > 127. ASCII is a 7-bit encoding. That's why you run into cp1252 all the time if you work with Western European languages, such as English. cp1252 is an 8-bit superset of ASCII designed for Western European languages. I believe it's true that the first 256 unicode code points are actually cp1252, which implies that the first 128 code points correspond with ASCII.
- beaumartinez 16y agoWindows-1252 (cp1252) is similar to ISO-8859-1 (Latin-1), which is a subset of Unicode; both are a superset of ASCII. Windows-1252 however has a few characters mapped to different codepoints.
- adamtj 16y agoThat's right, thank you.
- est 16y ago> There are no ASCII characters > 127. ASCII is a 7-bit encoding. Then there is no reason Python using ASCII to handle 8bit byte and yield error.
- timrobinson 16y agoThe Windows console does support encodings: see the `chcp` command, which changes the code page. The cmd.exe builtins can support UTF-16 regardless of the code page. When I last looked at this, Python doesn't attempt to deal with the Windows console code page.