summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/ext/widestring.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/ranger/ext/widestring.py b/ranger/ext/widestring.py
index 88565b89..31e41210 100644
--- a/ranger/ext/widestring.py
+++ b/ranger/ext/widestring.py
@@ -53,7 +53,15 @@ def string_to_charlist(string):
 
 class WideString(object):
     def __init__(self, string, chars=None):
-        self.string = string
+        try:
+            self.string = str(string)
+        except UnicodeEncodeError:
+            # Here I assume that string is a "unicode" object, because why else
+            # would str(string) raise a UnicodeEncodeError?
+            try:
+                self.string = string.encode('latin-1', 'ignore')
+            except:
+                self.string = ""
         if chars is None:
             self.chars = string_to_charlist(string)
         else:
107' href='#n107'>107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125