Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36348

Re: Problem with Unicode char in Python 3.3.0

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'string.': 0.04; 'subject:Python': 0.05; 'encode': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tcl/tk': 0.09; 'terry': 0.09; 'unicode,': 0.09; '(the': 0.15; 'codec': 0.16; 'fine.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:Problem': 0.16; 'subject:Unicode': 0.16; 'wrote:': 0.17; 'char': 0.17; 'widget': 0.17; 'jan': 0.18; '>>>': 0.18; 'windows': 0.19; 'skip:" 40': 0.20; '"",': 0.22; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'creating': 0.26; 'supported': 0.26; '(most': 0.27; 'am,': 0.27; 'header:X -Complaints-To:1': 0.28; 'character': 0.29; 'file': 0.32; 'message.': 0.33; 'idle': 0.33; 'traceback': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; "can't": 0.34; 'text': 0.34; 'especially': 0.35; 'received:org': 0.36; 'but': 0.36; 'subject:with': 0.36; 'problems': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'skip:u 10': 0.60; 'is.': 0.62; 'different': 0.63; 'skip:c 50': 0.66; 'brand': 0.78; '<<<': 0.84; 'ion': 0.84; 'received:fios.verizon.net': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: Problem with Unicode char in Python 3.3.0
Date Mon, 07 Jan 2013 08:12:57 -0500
References <nobody-672426.17430906012013@news.free.fr> <mailman.175.1357492817.2939.python-list@python.org> <nobody-940F87.13572507012013@news.free.fr>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-173-75-251-66.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0
In-Reply-To <nobody-940F87.13572507012013@news.free.fr>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.218.1357564437.2939.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357564437 news.xs4all.nl 6930 [2001:888:2000:d::a6]:35005
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36348

Show key headers only | View raw


On 1/7/2013 7:57 AM, Franck Ditter wrote:

> <<< print('\U0001d11e')
> Traceback (most recent call last):
>    File "<pyshell#1>", line 1, in <module>
>      print('\U0001d11e')
> UnicodeEncodeError: 'UCS-2' codec can't encode character '\U0001d11e'
> in position 0: Non-BMP character not supported in Tk

The message comes from printing to a tk text widget (the IDLE shell), 
not from creating the 1 char string. c = '\U0001d11e' works fine. When 
you have problems with creating and printing unicode, *separate* 
creating from printing to see where the problem is. (I do not know if 
the brand new tcl/tk 8.6 is any better.)

The windows console also chokes, but with a different message.

 >>> c='\U0001d11e'
 >>> print(c)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "C:\Programs\Python33\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 '\U0001d11e' 
in posit
ion 0: character maps to <undefined>

Yes, this is very annoying, especially in Win 7.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Problem with Unicode char in Python 3.3.0 Franck Ditter <nobody@nowhere.org> - 2013-01-06 17:43 +0100
  Re: Problem with Unicode char in Python 3.3.0 Peter Otten <__peter__@web.de> - 2013-01-06 18:03 +0100
  Re: Problem with Unicode char in Python 3.3.0 marduk <marduk@python.net> - 2013-01-06 12:10 -0500
    Re: Problem with Unicode char in Python 3.3.0 Franck Ditter <nobody@nowhere.org> - 2013-01-07 13:57 +0100
      Re: Problem with Unicode char in Python 3.3.0 Chris Angelico <rosuav@gmail.com> - 2013-01-08 00:04 +1100
      Re: Problem with Unicode char in Python 3.3.0 Terry Reedy <tjreedy@udel.edu> - 2013-01-07 08:12 -0500
      Re: Problem with Unicode char in Python 3.3.0 Terry Reedy <tjreedy@udel.edu> - 2013-01-08 03:40 -0500

csiph-web