diff options
author | Dan Williams <dcbw@redhat.com> | 2012-01-18 13:00:50 -0600 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2012-01-18 13:00:50 -0600 |
commit | 6789a87a5826638472b88d600b99414ce3daa5bd (patch) | |
tree | d765387878fbd2649fc55f1301aa27b8eee13fc8 /test | |
parent | 3f4056caab93ea4f208f5da4a8cd50de5fef52d8 (diff) |
tests: better handling of encodings in SMS test tool
Python usually uses Unicode, but often the shell encoding
will be in UTF-8, so Python needs some help converting the
message to Unicode. Use LANG to do that if we can.
Diffstat (limited to 'test')
-rwxr-xr-x | test/mm-send-sms.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/test/mm-send-sms.py b/test/mm-send-sms.py index 55d453c5..d4f9da63 100755 --- a/test/mm-send-sms.py +++ b/test/mm-send-sms.py @@ -17,13 +17,22 @@ import sys import dbus +import os if len(sys.argv) != 3: print "Usage: %s <number> <message>" % sys.argv[0] sys.exit(1) number = sys.argv[1] -message = sys.argv[2] + +try: + lang = os.getenv("LANG") + idx = lang.find(".") + if idx != -1: + lang = lang[idx + 1:] +except KeyError: + lang = "utf-8" +message = unicode(sys.argv[2], "utf-8") bus = dbus.SystemBus() |