Skip to content

Commit fcbaa4e

Browse files
authored
Support utf 8 (#679)
1 parent c90b484 commit fcbaa4e

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

tests/unit/twiml/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,11 @@ def test_lower_camel_multi_word_mixed_case(self):
5050

5151
def test_lower_camel_camel_cased(self):
5252
self.assertEqual("fooBar", lower_camel("fooBar"))
53+
54+
def test_utf8_encoding(self):
55+
t = TwiML()
56+
t.value = "An utf-8 character: ñ"
57+
self.assertEqual(
58+
t.to_xml(),
59+
'<?xml version="1.0" encoding="UTF-8"?><TwiML>An utf-8 character: ñ</TwiML>',
60+
)

tests/unit/twiml/test_voice_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_say_french(self):
7171

7272
assert (
7373
self.strip(r)
74-
== '<?xml version="1.0" encoding="UTF-8"?><Response><Say>n&#233;cessaire et d\'autres</Say></Response>'
74+
== '<?xml version="1.0" encoding="UTF-8"?><Response><Say>nécessaire et d\'autres</Say></Response>'
7575
)
7676

7777
def test_say_loop(self):

twilio/twiml/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def to_xml(self, xml_declaration=True):
6464
6565
:param bool xml_declaration: Include the XML declaration. Defaults to True
6666
"""
67-
xml = ET.tostring(self.xml()).decode("utf-8")
67+
xml = ET.tostring(self.xml(), encoding="utf-8").decode("utf-8")
6868
return (
6969
'<?xml version="1.0" encoding="UTF-8"?>{}'.format(xml)
7070
if xml_declaration

0 commit comments

Comments
 (0)