Problem with Unicode char in Python 3.3.0

Franck Ditter nobody at nowhere.org
Mon Jan 7 13:57:26 CET 2013


In article <mailman.175.1357492817.2939.python-list at python.org>,
 marduk <marduk at python.net> wrote:

> On Sun, Jan 6, 2013, at 11:43 AM, Franck Ditter wrote:
> > Hi !
> > I work on MacOS-X Lion and IDLE/Python 3.3.0
> > I can't get the treble key (U1D11E) !
> > 
> > >>> "\U1D11E"
> > SyntaxError: (unicode error) 'unicodeescape' codec can't 
> > decode bytes in position 0-6: end of string in escape sequence
> > 
> 
> You probably meant:
> 
> >>> '\U0001d11e'
> 
> 
> For that synax you must use either '\uXXXX' or '\UXXXXXXXX' (i.e.
> specify either 4 or 8 hex digits).
> 
> http://docs.python.org/2/howto/unicode#unicode-literals-in-python-source-code

<<< 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



More information about the Python-list mailing list