summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2013-02-13 01:57:59 +0100
committerhut <hut@lavabit.com>2013-02-13 01:57:59 +0100
commitce65794595963f9f72a3022735acdc711412b262 (patch)
treec1c9d6ef81725f1bd5bae5eeaa05f84093f22529 /ranger
parent9f304f0745b97db6a52fb3eb6b2b5ad228432096 (diff)
downloadranger-ce65794595963f9f72a3022735acdc711412b262.tar.gz
ext.widestring: catch a wild UnicodeEncodeError
Diffstat (limited to 'ranger')
-rw-r--r--ranger/ext/widestring.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/ranger/ext/widestring.py b/ranger/ext/widestring.py
index dac54efd..88565b89 100644
--- a/ranger/ext/widestring.py
+++ b/ranger/ext/widestring.py
@@ -36,7 +36,14 @@ def string_to_charlist(string):
             if east_asian_width(c) in WIDE_SYMBOLS:
                 result.append('')
     else:
-        string = string.decode('utf-8', 'ignore')
+        try:
+            # This raised a "UnicodeEncodeError: 'ascii' codec can't encode
+            # character u'\xe4' in position 10: ordinal not in range(128)"
+            # for me once.  I thought errors='ignore' means IGNORE THE DAMN
+            # ERRORS but apparently it doesn't.
+            string = string.decode('utf-8', 'ignore')
+        except UnicodeEncodeError:
+            return []
         for c in string:
             result.append(c.encode('utf-8'))
             if east_asian_width(c) in WIDE_SYMBOLS: