From 201d2a2434c18c191b247b8d36f800b3c1fe00da Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 23 Apr 2021 16:15:24 +0200 Subject: [PATCH] lang-check: handle backslash sequences --- lang/lang-check.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lang/lang-check.py b/lang/lang-check.py index 4d08ba58..bd073e2b 100755 --- a/lang/lang-check.py +++ b/lang/lang-check.py @@ -48,6 +48,12 @@ def print_truncated(text, cols): print(' |' + prefix + '|' + suffix) +def unescape(text): + if '\\' not in text: + return text + return text.encode('ascii').decode('unicode_escape') + + def parse_txt(lang, no_warning): """Parse txt file and check strings to display definition.""" if lang == "en": @@ -94,6 +100,11 @@ def parse_txt(lang, no_warning): if translation == '\\x00': # crude hack to handle intentionally-empty translations translation = '' + + # handle backslash sequences + source = unescape(source) + translation = unescape(translation) + #print (translation) #Debug wrapped_source = list(textwrap.TextWrapper(width=cols).wrap(source)) rows_count_source = len(wrapped_source)