On Jan 27, 11:52 pm, "Giampaolo Rodola'" <gne...@gmail.com> wrote: > On 26 Gen, 19:16, jefm <jef.mangelsch...@gmail.com> wrote: > > > > > Hi, > > while checking out Python 3, I read that all text strings are now > > natively Unicode. > > In the Python language reference (http://docs.python.org/3.0/reference/ > > lexical_analysis.html) I read that I can show Unicode character in > > several ways. > > "\uxxxx" supposedly allows me to specify the Unicode character by hex > > number and the format "\N{name}" allows me to specify by Unicode > > name. > > Neither seem to work for me. > > What am I doing wrong ? > > > Please see error output below where I am trying to show the EURO sign > > (http://www.fileformat.info/info/unicode/char/20ac/index.htm): > > > Python 3.0 (r30:67507, Dec 3 2008, 20:14:27) [MSC v.1500 32 bit > > (Intel)] on win32 > > Type "help", "copyright", "credits" or "license" for more information.>>> > > print('\u20ac') > > > 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\cp437.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> > > > >>> print ("\N{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\cp437.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> > > I have this same issue on Windows. > Note that on Python 2.6 it works: > > 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 is pretty serious, IMHO, since breaks any Windows software > priting unicode to stdout. > I've filed an issue on the Python bug tracker:http://bugs.python.org/issue5081
Hello hello -- (1) that's *not* attempting to print Unicode. Look at your own output ... "\u20ac"" was printed, not a euro character!!! With 2.X for *any* X: >>> guff ='\u20ac' >>> type(guff) <type 'str'> >>> len(guff) 6 (2) Printing Unicode to a Windows console has never *worked*; that's why this thread was pursuing the faint ray of hope offered by cp65001. -- http://mail.python.org/mailman/listinfo/python-list