[XML-SIG] outputting non-ascii strings

Matt Patterson matt@reprocessed.org
Wed, 22 May 2002 21:39:54 +0100


On 22/5/02, Martin v. Loewis wrote:

> "Juergen Hermann" <jh@web.de> writes:
> 
> > Implicit: Use codecs.lookup('utf-8') to get reader/writer wrappers,
> > then you say utf8_stdout = utf8_wrapper(sys.stdout)
> 
> Since Python 2.2, it is better to use codecs.getwriter("utf-8"), since
> that saves the trouble of knowing in which order the result of .lookup
> is.

I'm using Python 2.1.3, and PyXML 0.7, so that isn't an option for me,
and as I said to Juergen - I'm still a python newbie, and the
reader/writer wrappers thing is a bit beyond me...

The other thing that's cropped up now - using Juergen's suggestion to
use stream.write(ustring.encode('utf-8')), which works a treat, decodes
all the entities in the text, so I now have free-floating ampersands and
angle brackets, where before I had entities. I do have typographer's
quotes still :-)

Is there an easy way around this problem? I've looked through my Python
books (Learning Python, Programming Python, Python and XML) and can't
find a comprehensive treatment of this issue - if there is one I'd like
to know, please! Is there a good place to go and look for such
documentation?

Thanks again

Matt


-- 
   Matt Patterson | Typographer
   <matt@reprocessed.org> | http://reprocessed.org/