Permalink
Browse files

Fixed up to_xml dumping of entire domains to properly handle unicode …

…characters
  • Loading branch information...
1 parent a9e0f2a commit 18ff75a04db1caf1f76121416feb3edef1da29ed kopertop committed Nov 25, 2009
Showing with 7 additions and 1 deletion.
  1. +7 −1 boto/sdb/domain.py
View
@@ -207,7 +207,13 @@ def to_xml(self, f=None):
if not isinstance(values, list):
values = [values]
for value in values:
- print >>f, '\t\t\t<value><![CDATA[ %s ]]></value>' % (str(value.encode('utf-8')))
+ print >>f, '\t\t\t<value><![CDATA[',
+ if isinstance(value, unicode):
+ value = value.encode('utf-8', 'replace')
+ else:
+ value = unicode(value, errors='replace').encode('utf-8', 'replace')
+ f.write(value)
+ print >>f, ']]></value>'
print >>f, '\t\t</attribute>'
print >>f, '\t</Item>'
print >>f, '</Domain>'

0 comments on commit 18ff75a

Please sign in to comment.