[Zope] How to display unicode character given its code

Dieter Maurer dieter at handshake.de
Tue Jul 26 12:55:48 EDT 2005


Itai Tavor wrote at 2005-7-26 11:20 +1000:
> ...
>Couldn't get it to work, though... not sure why: unicode('\u2013')  
>returns u'\\u2013', which is useless.

I know why (now, that you report the problem).

  '...' introduces a non unicode string in which "\u" is not recognized.
  "\u" is only recognized in unicode strings.
  They are introduced by "u'...'".

Thus, instead of "unicode('\u2013').encode('utf-8')", I should
have written "u'\u2013'.encode('utf-8')".

-- 
Dieter


More information about the Zope mailing list