summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-10-23 19:55:42 +0200
committerhut <hut@lavabit.com>2011-10-23 19:55:42 +0200
commit97e724a3f590210a819414de3c21278d2f3c03dc (patch)
treee2a536d122c48a470fae0ae4e3bb6bcda75a4a53
parent3c0fd67fd5581bb1aaa84c957b568abdb5dc1a54 (diff)
downloadranger-97e724a3f590210a819414de3c21278d2f3c03dc.tar.gz
gui.curses_shortcuts: Fix unicode bug with surrogates
-rw-r--r--ranger/gui/curses_shortcuts.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/ranger/gui/curses_shortcuts.py b/ranger/gui/curses_shortcuts.py
index a977beda..4a3bb4b9 100644
--- a/ranger/gui/curses_shortcuts.py
+++ b/ranger/gui/curses_shortcuts.py
@@ -21,6 +21,10 @@ from ranger.ext.iter_tools import flatten
 from ranger.gui.color import get_color
 from ranger.core.shared import SettingsAware
 
+def _fix_surrogates(args):
+	return [isinstance(arg, str) and arg.encode('utf-8', 'surrogateescape')
+			.decode('utf-8', 'replace') or arg for arg in args]
+
 class CursesShortcuts(SettingsAware):
 	"""
 	This class defines shortcuts to faciliate operations with curses.
@@ -35,13 +39,19 @@ class CursesShortcuts(SettingsAware):
 		try:
 			self.win.addstr(*args)
 		except:
-			pass
+			try:
+				self.win.addstr(*_fix_surrogates(args))
+			except:
+				pass
 
 	def addnstr(self, *args):
 		try:
 			self.win.addnstr(*args)
 		except:
-			pass
+			try:
+				self.win.addnstr(*_fix_surrogates(args))
+			except:
+				pass
 
 	def addch(self, *args):
 		try:
a48a32387451afdca44'>^
49271e46 ^
3c59f985 ^

63770815 ^
3c59f985 ^
63770815 ^





3c59f985 ^
63770815 ^

3c59f985 ^
63770815 ^




3c59f985 ^
63770815 ^


3c59f985 ^
63770815 ^



5dbef8ad ^
63770815 ^

3c59f985 ^

63770815 ^
3c59f985 ^
63770815 ^

3c59f985 ^

63770815 ^
3c59f985 ^
63770815 ^

3c59f985 ^

63770815 ^
3c59f985 ^
63770815 ^

3c59f985 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82