You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
print() encodes characters to native system encoding #58461
bpo-1602: windows console doesn't print or input Unicode
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2012-03-11.18:18:17.118>created_at=<Date2012-03-11.16:39:43.676>labels= ['type-bug', 'expert-unicode']
title='print() encodes characters to native system encoding'updated_at=<Date2012-03-11.18:18:17.115>user='https://bugs.python.org/RobertSjblom'
I'm on a cp932-encoded system. When I read in a cp1252-file, it's read into memory properly, but when printing it, Python tries to encode the output to cp932. Here's the relevant code:
Traceback (most recent call last):
File "C:\Python32\parser.py",
line 8, in <module>
print(line)
UnicodeEncodeError: 'cp932' codec can't encode character '\xe9' in
position 13: illegal multibyte sequence
Robert: this is not a bug. Python's IO stack has the fundamental assumption that streams are byte-oriented. So the "shouldn't be the output in Unicode" is not a possible solution, since Unicode cannot work on a byte stream.
As a feature request, this is indeed a duplicate of 1602.
Activity
RobertSjblom commentedon Mar 11, 2012
I'm on a cp932-encoded system. When I read in a cp1252-file, it's read into memory properly, but when printing it, Python tries to encode the output to cp932. Here's the relevant code:
Shouldn't the output be in unicode?
pitrou commentedon Mar 11, 2012
Probably a duplicate of bpo-1602.
loewis commentedon Mar 11, 2012
Robert: this is not a bug. Python's IO stack has the fundamental assumption that streams are byte-oriented. So the "shouldn't be the output in Unicode" is not a possible solution, since Unicode cannot work on a byte stream.
As a feature request, this is indeed a duplicate of 1602.