Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to print Unicode characters in Python 3 on Windows #49331

Closed
giampaolo opened this issue Jan 27, 2009 · 2 comments
Closed

Unable to print Unicode characters in Python 3 on Windows #49331

giampaolo opened this issue Jan 27, 2009 · 2 comments
Labels
type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@giampaolo
Copy link
Contributor

BPO 5081
Nosy @loewis, @giampaolo

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 = None
closed_at = <Date 2009-01-27.18:13:00.622>
created_at = <Date 2009-01-27.12:51:55.941>
labels = ['type-crash']
title = 'Unable to print Unicode characters in Python 3 on Windows'
updated_at = <Date 2009-01-27.18:13:00.604>
user = 'https://github.com/giampaolo'

bugs.python.org fields:

activity = <Date 2009-01-27.18:13:00.604>
actor = 'loewis'
assignee = 'none'
closed = True
closed_date = <Date 2009-01-27.18:13:00.622>
closer = 'loewis'
components = ['None']
creation = <Date 2009-01-27.12:51:55.941>
creator = 'giampaolo.rodola'
dependencies = []
files = []
hgrepos = []
issue_num = 5081
keywords = []
message_count = 2.0
messages = ['80650', '80665']
nosy_count = 2.0
nosy_names = ['loewis', 'giampaolo.rodola']
pr_nums = []
priority = 'normal'
resolution = 'works for me'
stage = None
status = 'closed'
superseder = None
type = 'crash'
url = 'https://bugs.python.org/issue5081'
versions = ['Python 3.0', 'Python 3.1']

@giampaolo
Copy link
Contributor Author

While trying to port pyftpdlib to Python 3.x I noticed that Python 3.0
has a serious issue since unable to print certain unicode characters on
stdout:

Python 3.0 (r30:67507, Dec  3 2008, 20:14:27) [MSC v.1500 32 bit
(Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> print('\u20ac')  # euro sign
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\python30\lib\io.py", line 1491, in write
    b = encoder.encode(s)
  File "C:\python30\lib\encodings\cp850.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u20ac' in
position
0: character maps to <undefined>
>>>

Note that the same thing works on Python 2.6

Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print unicode('\u20ac')
\u20ac

This same thing is also discussed on python ml:
http://groups.google.it/group/comp.lang.python/browse_thread/thread/fb42765fe7476fc9/f560b4eaf2b0e3f4?hl=it&pli=1

@giampaolo giampaolo added the type-crash A hard crash of the interpreter, possibly with a core dump label Jan 27, 2009
@loewis
Copy link
Mannequin

loewis mannequin commented Jan 27, 2009

Your 2.6 example is incorrect. Try

py> print u'\u20ac'

If you want the 3.0 equivalent of your 2.6 code: it is

py> print(r'\u20ac')
\u20ac

Closing this as "works for me".

@loewis loewis mannequin closed this as completed Jan 27, 2009
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

1 participant