Skip to contentSkip to conversation

monitor-ofono: Fix to print non-English characters

PATCH In review Philippe Nunes 2 participants 4 messages Jul 26, 2012 – Jul 27, 2012 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 monitor-ofono: Fix to print non-English characters

The default encoding for a Python bytestring is ASCII. But the SMS/USSD text is encoded in UTF-8.
This is why trying to convert non-English characters (Unicode characters beyond 128) produces the error "UnicodeEncodeError: 'ascii' codec can't encode character".

---
 test/monitor-ofono |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
test/monitor-ofono +2 -2
index 8570c34..dcc5ff5 100755
@@ -69,11 +69,11 @@ def event(member, path, interface):
 def message(msg, args, member, path, interface):
 	iface = interface[interface.rfind(".") + 1:]
 	print "{%s} [%s] %s %s (%s)" % (iface, path, member,
-					str(msg), pretty(args))
+					msg, pretty(args))
 
 def ussd(msg, member, path, interface):
 	iface = interface[interface.rfind(".") + 1:]
-	print "{%s} [%s] %s %s" % (iface, path, member, str(msg))
+	print "{%s} [%s] %s %s" % (iface, path, member, msg)
 
 def value(value, member, path, interface):
 	iface = interface[interface.rfind(".") + 1:]
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/1 test-ussd becomes send-ussd This script can be used to handle network initiated USSDs

---
 Makefile.am    |    2 +-
 test/send-ussd |   57 ++++++++++++++++++++++++++++++++++++++++++
 test/test-ussd |   75 --------------------------------------------------------
 3 files changed, 58 insertions(+), 76 deletions(-)
 create mode 100755 test/send-ussd
 delete mode 100755 test/test-ussd
Makefile.am +1 -1
index e012d3f..b35cf1f 100644
@@ -583,7 +583,7 @@ test_scripts = test/backtrace \
 		test/test-ss-control-cf \
 		test/test-ss-control-cs \
 		test/test-voicecall \
-		test/test-ussd \
+		test/send-ussd \
 		test/cancel-ussd \
 		test/initiate-ussd \
 		test/offline-modem \
test/send-ussd new file +57 -0

57 lines not on this page · raw message

test/test-ussd deleted +0 -75

75 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH v2] test-ussd becomes send-ussd This script can be used to handle network initiated USSDs

Hi Philippe,

Quoted 8 lines · Philippe Nunes
---
  Makefile.am    |    2 +-
  test/send-ussd |   57 ++++++++++++++++++++++++++++++++++++++++++
  test/test-ussd |   75 --------------------------------------------------------
  3 files changed, 58 insertions(+), 76 deletions(-)

create mode 100755 test/send-ussd
delete mode 100755 test/test-ussd

I applied this patch but broke it into two to make git history a bit easier to follow.

Regards,
-Denis

#3 lore raw
In reply to Philippe Nunes

Hi Philippe,

Quoted 9 lines · Philippe Nunes

The default encoding for a Python bytestring is ASCII. But the SMS/USSD text is encoded in UTF-8.
This is why trying to convert non-English characters (Unicode characters beyond 128) produces the error "UnicodeEncodeError: 'ascii' codec can't encode character".

---
  test/monitor-ofono |    4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

Patch has been applied, thanks.

Regards,
-Denis