Re: Problem with xmlproc

Mike Brown <[email protected]>
Newsgroups gmane.comp.python.xml
Message-ID <[email protected]>
Marco Meoni wrote:
> thanks!!!
> i have understood the u operator.
> One question:
> 1)WHY MY CODE PUT THE u OPERATOR IN THE VIDEO OUTPUT?

Fundamentally, an XML document is a sequence of Unicode characters,
independent of any encoding. Therefore, when a the contents of a document or
DTD are being read, it is often very convenient for APIs to use Python's
unicode type as a means of reporting what is in the document. That's why the
unicode objects exist for you. (Although, I would not count on xmlproc to be
consistent about returning unicode).

As for why you see them printed as u'...', that's because you are "print"-ing
tuples and lists that contain unicode objects. If you instead print the
unicode objects individually, rather than their containers, then the unicode
strings will be encoded for you automatically to whatever Python thinks your
screen can handle.

>>> print [u'hello world', u'greetings']
[u'hello world', u'greetings']
>>> print u'hello world'
hello world

_______________________________________________
XML-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/xml-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.