[XML-SIG] [OT] working unicode strings

Alexandre Fayolle Alexandre.Fayolle@logilab.fr
Thu, 28 Jun 2001 16:26:19 +0200 (CEST)


Ahem, sorry for posting this here, since it is slightly off-topic, but
this list is a place where I know I'll find people who have played with
unicode strings in Python.

So, I have a UTF8 encoded unicode string, that I got it by reading a text
node in a DOM. I want to write it somewhere on the disk. 

s= u'été'
f=open('/tmp/foo','w')
f.write(s)

This gets me 
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
UnicodeError: ASCII encoding error: ordinal not in range(128)

By experimenting a bit, it appears that I can call f.write(s) when f is a
StringIO.StringIO, but not when it is a cStringIO.StringIO, a file, or a
standard stream (sys.stdout). Needless to say, I'm quite disapointed. 

So the first question is, how do you manage to work with unicode strings
in PyXML/4Suite (a pointer to the right source file is a valuable answer).

The second question is, where is the right place to discuss these issues ?

The third question is, does anyone know if this state of things is likely
to change in python 2.2 ?

Alexandre Fayolle
-- 
http://www.logilab.com 
Narval is the first software agent available as free software (GPL).
LOGILAB, Paris (France).