From 6789a87a5826638472b88d600b99414ce3daa5bd Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 18 Jan 2012 13:00:50 -0600 Subject: 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. --- test/mm-send-sms.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'test') 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 " % 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() -- cgit v1.2.3-70-g09d2