News for hackers. Stuff that matters.
Re:Unicode In Python, Completely Demystified by est on Saturday February 26, 2011 @10:10AM (#2265669)
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.

Re:Unicode In Python, Completely Demystified by adamtj on Saturday February 26, 2011 @11:21AM (#2265831)
There 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.
Re:Unicode In Python, Completely Demystified by beaumartinez on Saturday February 26, 2011 @11:59AM (#2265903)
Windows-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.
Re:Unicode In Python, Completely Demystified by adamtj on Saturday February 26, 2011 @02:01PM (#2266234)
That's right, thank you.
Re:Unicode In Python, Completely Demystified by est on Saturday February 26, 2011 @08:16PM (#2267033)
> 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.

Re:Unicode In Python, Completely Demystified by timrobinson on Saturday February 26, 2011 @11:27AM (#2265848)
The 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.

Re:Unicode In Python, Completely Demystified by piranha on Saturday February 26, 2011 @11:17AM (#2265820)
Hm, strange, I have no problems using cp866 to print something to console on Windows.