Unicode support?

2 views
Skip to first unread message

Adam V.

unread,
Oct 21, 2009, 6:28:10 PM10/21/09
to xmlwitch-dev
How do I output text w/ unicode characters?

xml = xmlwitch.builder()
with xml.root as node:
# \xa9 == Unicode code point for (C) symbol.
xml.name(u"This text is \xa9 2009 Some Guy Productions.")


The code above fails with:
UnicodeEncodeError: ascii, <name>This text is © 2009 Some Guy
Productions.</name>, 19, 20, ordinal not in range(128)

Jonas Galvez

unread,
Oct 21, 2009, 7:35:04 PM10/21/09
to xmlwit...@googlegroups.com
Quick answer, xmlwitch expects UTF-8 text, so this works:

xml = xmlwitch.builder('1.0', 'utf-8')
with xml.root:
  xml.name('This text is \xc2\xa9 2009 Some Guy Productions.')

But yeah, it should work with Unicode strings as well. Gonna look into that.

--Jonas

Jonas Galvez

unread,
Oct 21, 2009, 7:47:03 PM10/21/09
to xmlwit...@googlegroups.com
Just noticed you've been doing some work on your 'more' branch. Good call with the PEP8 compliance. Gonna try and merge some of that stuff later.

--Jonas
Reply all
Reply to author
Forward
0 new messages