Skip to content

Instantly share code, notes, and snippets.

@ironpythonbot
Created December 9, 2014 17:50
Show Gist options
  • Save ironpythonbot/72a6a557c77d0bb6d1c6 to your computer and use it in GitHub Desktop.
Save ironpythonbot/72a6a557c77d0bb6d1c6 to your computer and use it in GitHub Desktop.
CodePlex Issue #29474 Plain Text Attachments
import unittest
from xml.sax.saxutils import XMLGenerator
from StringIO import StringIO
class TestXmlGenerator(unittest.TestCase):
def test_encoding(self):
input = u'hyv\xe4'
output = StringIO()
XMLGenerator(output, encoding='UTF-8').characters(input)
self.assertEquals(output.getvalue(), input.encode('UTF-8'))
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment