twilio/twilio-python — Issue #39: errors with unicode in outgoing SMS messages
Author: jklundell
Created: 2011-12-12 05:53:37+00:00
State: open

Sending an SMS text via client.sms.messages.create(to=to_phone, from_=from_phone, body=body), if body is a unicode string and has a non-ascii character, we eventually get:

Exception Type:	UnicodeEncodeError
Exception Value:
'ascii' codec can't encode character u'\u2014' in position 71: ordinal not in range(128)
Exception Location:	/usr/lib/python2.7/urllib.py in urlencode, line 1282

Moreover, if I encode body to utf-8 before the call, the call succeeds, but the recipient (iPhone 4 running iOS 5.0.1) shows ? in place of the character in question (an em-dash in my test). iOS ordinarily handles such characters OK, at least phone-to-phone.