[orca] More work on the Hungarian unicode decode error bug (659122)



commit 94bcd8fce302b2325e24edcac03668a0547f6424
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Sun Sep 18 21:24:38 2011 -0400

    More work on the Hungarian unicode decode error bug (659122)

 src/orca/braille.py          |    2 +-
 src/orca/script_utilities.py |   18 ++++++++++++++----
 src/orca/speech.py           |    7 ++++++-
 3 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/src/orca/braille.py b/src/orca/braille.py
index 43099f9..4aa0892 100644
--- a/src/orca/braille.py
+++ b/src/orca/braille.py
@@ -354,7 +354,7 @@ class Region:
         try:
             string = string.decode("UTF-8")
         except UnicodeEncodeError:
-            debug.printException(debug.LEVEL_FINEST)
+            pass
 
         # The uncontracted string for the line.
         #
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index e2323d0..3e29dce 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -2609,13 +2609,23 @@ class Utilities:
         and returns the new string.  Edge cases, such as no initial text or
         no newText, are handled gracefully."""
 
-        if not newText or len(newText) == 0:
+        if not newText:
             return text
-        elif text and len(text):
-            return text + delimiter + newText
-        else:
+        if not text:
             return newText
 
+        try:
+            text = text.decode("UTF-8")
+        except UnicodeEncodeError:
+            pass
+
+        try:
+            newText = newText.decode("UTF-8")
+        except UnicodeEncodeError:
+            pass
+
+        return text + delimiter + newText
+
     def isAutoTextEvent(self, event):
         """Returns True if event is associated with text being autocompleted
         or autoinserted or autocorrected or autosomethingelsed.
diff --git a/src/orca/speech.py b/src/orca/speech.py
index b05f1f9..d8ae598 100644
--- a/src/orca/speech.py
+++ b/src/orca/speech.py
@@ -249,6 +249,11 @@ def speak(content, acss=None, interrupt=True):
                 newItemsToSpeak.append(toSpeak.pop())
 
             if toSpeak:
+                try:
+                    toSpeak = map(lambda x: x.decode("UTF-8"), toSpeak)
+                except UnicodeEncodeError:
+                    pass
+
                 string = " ".join(toSpeak)
                 _speak(string, activeVoice, interrupt)
             activeVoice = newVoice
@@ -261,7 +266,7 @@ def speak(content, acss=None, interrupt=True):
         try:
             toSpeak = map(lambda x: x.decode("UTF-8"), toSpeak)
         except UnicodeEncodeError:
-            debug.printException(debug.LEVEL_FINEST)
+            pass
 
         string = " ".join(toSpeak)
         _speak(string, activeVoice, interrupt)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]