summaryrefslogtreecommitdiff
path: root/sphinx/util/console.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/util/console.py')
-rw-r--r--sphinx/util/console.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/sphinx/util/console.py b/sphinx/util/console.py
index b419e1284..c207d32ac 100644
--- a/sphinx/util/console.py
+++ b/sphinx/util/console.py
@@ -27,6 +27,12 @@ _ansi_re = re.compile('\x1b\\[(\\d\\d;){0,2}\\d\\dm')
codes = {} # type: Dict[str, str]
+def terminal_safe(s):
+ # type: (str) -> str
+ """safely encode a string for printing to the terminal."""
+ return s.encode('ascii', 'backslashreplace').decode('ascii')
+
+
def get_terminal_width():
# type: () -> int
"""Borrowed from the py lib."""