All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] test: According the current locale, replace non-codable character with '?'
  2011-06-29 13:07 [PATCH] test: According the current locale, replace non-codable character with '?' Philippe Nunes
@ 2011-06-29  5:05 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2011-06-29  5:05 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 310 bytes --]

Hi Philippe,

On 06/29/2011 08:07 AM, Philippe Nunes wrote:
> ---
>  test/test-stk-menu |   45 +++++++++++++++++++++++++--------------------
>  1 files changed, 25 insertions(+), 20 deletions(-)

I question the need for this patch, are you using a non-UTF8 locale for
some reason?

Regards,
-Denis

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] test: According the current locale, replace non-codable character with '?'
@ 2011-06-29 13:07 Philippe Nunes
  2011-06-29  5:05 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Nunes @ 2011-06-29 13:07 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 6810 bytes --]

---
 test/test-stk-menu |   45 +++++++++++++++++++++++++--------------------
 1 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/test/test-stk-menu b/test/test-stk-menu
index a9f92e8..0341385 100755
--- a/test/test-stk-menu
+++ b/test/test-stk-menu
@@ -1,5 +1,4 @@
 #!/usr/bin/python
-
 import gobject
 
 import sys
@@ -7,6 +6,8 @@ import dbus
 import dbus.service
 import dbus.mainloop.glib
 
+locale = sys.stdout.encoding
+
 class GoBack(dbus.DBusException):
 	_dbus_error_name = "org.ofono.Error.GoBack"
 
@@ -32,11 +33,12 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 				in_signature="sya(sy)n", out_signature="y")
 	def RequestSelection(self, title, icon, items, default):
-		print "Title: (%s)" % (title)
+		print "Title: (%s)" % (title.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		index = 0;
 		for item in items:
-			print "%d. %s (icon: %d)" % (index, item[0], item[1])
+			print "%d. %s (icon: %d)" % (index,
+				item[0].encode(locale, 'replace'), item[1])
 			index += 1
 
 		print "\nDefault: %d" % (default)
@@ -52,7 +54,7 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 					in_signature="syb", out_signature="")
 	def DisplayText(self, title, icon, urgent):
-		print "DisplayText (%s)" % (title)
+		print "DisplayText (%s)" % (title.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		print "Urgent: (%d)" % (urgent)
 		key = raw_input("Press return to clear ('t' terminates, "
@@ -69,7 +71,7 @@ class StkAgent(dbus.service.Object):
 				in_signature="sysyyb", out_signature="s")
 	def RequestInput(self, title, icon, default, min_chars, max_chars,
 				hide_typing):
-		print "Title: (%s)" % (title)
+		print "Title: (%s)" % (title.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		print "Default: (%s)" % (default)
 		print "Hide typing: (%s)" % (hide_typing)
@@ -83,7 +85,7 @@ class StkAgent(dbus.service.Object):
 				in_signature="sysyyb", out_signature="s")
 	def RequestDigits(self, title, icon, default, min_chars, max_chars,
 				hide_typing):
-		print "Title: (%s)" % (title)
+		print "Title: (%s)" % (title.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		print "Default: (%s)" % (default)
 		print "Hide typing: (%s)" % (hide_typing)
@@ -101,7 +103,7 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 				in_signature="sy", out_signature="s")
 	def RequestKey(self, title, icon):
-		print "Title: (%s)" % (title)
+		print "Title: (%s)" % (title.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		key = raw_input("Enter Key (t, b):")
 
@@ -115,7 +117,7 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 				in_signature="sy", out_signature="s")
 	def RequestDigit(self, title, icon):
-		print "Title: (%s)" % (title)
+		print "Title: (%s)" % (title.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		key = raw_input("Enter Digit (t, b):")
 
@@ -129,7 +131,7 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 				in_signature="sy", out_signature="b")
 	def RequestConfirmation(self, title, icon):
-		print "Title: (%s)" % (title)
+		print "Title: (%s)" % (title.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		key = raw_input("Enter Confirmation (t, b, y, n):")
 
@@ -145,7 +147,7 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 				in_signature="sy", out_signature="b")
 	def ConfirmCallSetup(self, info, icon):
-		print "Information: (%s)" % (info)
+		print "Information: (%s)" % (info.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		key = raw_input("Enter Confirmation (t, y, n):")
 
@@ -159,9 +161,9 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 				in_signature="sys", out_signature="b")
 	def ConfirmLaunchBrowser(self, info, icon, url):
-		print "Information: (%s)" % (info)
+		print "Information: (%s)" % (info.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
-		print "URL (%s)" % (url)
+		print "URL (%s)" % (url.encode(locale, 'replace'))
 		key = raw_input("Enter Confirmation (y, n):")
 
 		if key == 'y':
@@ -177,15 +179,15 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 					in_signature="ssy", out_signature="")
 	def PlayTone(self, tone, text, icon):
-		print "PlayTone: %s" % (tone)
-		print "Text: %s" % (text)
+		print "PlayTone: %s" % (tone.encode(locale, 'replace'))
+		print "Text: %s" % (text.encode(locale, 'replace'))
 		print "Icon: %d" % (icon)
 
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 					in_signature="ssy", out_signature="")
 	def LoopTone(self, tone, text, icon):
 		print "LoopTone: %s" % (tone)
-		print "Text: %s" % (text)
+		print "Text: %s" % (text.encode(locale, 'replace'))
 		print "Icon: %d" % (icon)
 		key = raw_input("Press return to end before timeout (t):")
 
@@ -195,13 +197,13 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 					in_signature="sy", out_signature="")
 	def DisplayActionInformation(self, text, icon):
-		print "Text: %s" % (text)
+		print "Text: %s" % (text.encode(locale, 'replace'))
 		print "Icon: %d" % (icon)
 
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 					in_signature="sy", out_signature="")
 	def DisplayAction(self, text, icon):
-		print "Text: (%s)" % (text)
+		print "Text: (%s)" % (text.encode(locale, 'replace'))
 		print "Icon: (%d)" % (icon)
 		key = raw_input("Press 't' to terminate the session ")
 
@@ -211,7 +213,8 @@ class StkAgent(dbus.service.Object):
 	@dbus.service.method("org.ofono.SimToolkitAgent",
 					in_signature="sy", out_signature="b")
 	def ConfirmOpenChannel(self, info, icon):
-		print "Open channel confirmation: (%s)" % (info)
+		print "Open channel confirmation: (%s)" % (info.encode(locale,
+								'replace'))
 		print "Icon: (%d)" % (icon)
 		key = raw_input("Enter Confirmation (t, y, n):")
 
@@ -253,14 +256,16 @@ if __name__ == '__main__':
 	if mode == 'menu':
 		if "MainMenuTitle" in properties:
 			print "Main Menu:"
-			print "%s" % (properties["MainMenuTitle"])
+			menu = properties["MainMenuTitle"]
+			print "%s" % (menu.encode(locale, 'replace'))
 			print "\n"
 
 		if "MainMenu" in properties:
 			print "Items:"
 			index = 0
 			for item in properties["MainMenu"]:
-				print "%d. %s" % (index, item[0])
+				print "%d. %s" % (index, item[0].encode(locale,
+							'replace'))
 				index += 1
 
 		path = "/test/agent"
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-29 13:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-29 13:07 [PATCH] test: According the current locale, replace non-codable character with '?' Philippe Nunes
2011-06-29  5:05 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.