commit 49583b7dd0fd2e31b08fd8c006de001a89f21de3
Author: Günter Milde <[email protected]>
Date:   Wed Jan 23 11:06:04 2019 +0100

    Fix encoding issue with lyx2lyx conversion of "Date" info-insets.
    
    Remaining problem: the name of the day appears in English instead of the 
document language.
---
 development/autotests/unreliableTests |    7 ++++---
 lib/lyx2lyx/lyx_2_4.py                |    4 ++++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/development/autotests/unreliableTests 
b/development/autotests/unreliableTests
index f23fc01..f7a8fc5 100644
--- a/development/autotests/unreliableTests
+++ b/development/autotests/unreliableTests
@@ -67,9 +67,6 @@ export/examples/(|fr/)seminar_(dvi|pdf).*
 # See also #9744 allow parallel configuration of TeX and non-TeX fonts.
 export/templates/acmart_pdf[45]_texF
 
-# "UnicodeDecodeError" with Python 2
-export/examples/ja/multilingual_lyx.*
-
 
 Sublabel: wrong_output
 ######################
@@ -119,3 +116,7 @@ export/export/latex/ru-accent-ascii_pdf2
 export/templates/acmart_dvi.*
 #export/templates/acmart_ps # not tested by ctest autotests
 export/templates/acmart_pdf
+
+# lyx2lyx back-conversion of "Date" info-inset writes 
+# the name of the day in English instead of Japanese.
+export/examples/ja/multilingual_lyx.*
diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py
index 7306193..85f7314 100644
--- a/lib/lyx2lyx/lyx_2_4.py
+++ b/lib/lyx2lyx/lyx_2_4.py
@@ -1094,6 +1094,10 @@ def revert_dateinfo(document):
             fmt = re.sub('[^\'%]d', '%d', fmt)
             fmt = fmt.replace("'", "")
             result = dte.strftime(fmt)
+        if sys.version_info < (3,0):
+            # In Python 2, datetime module works with binary strings,
+            # our dateformat strings are utf8-encoded:
+            result = result.decode('utf-8')
         document.body[i : j+1] = result
         i = i + 1
 

Reply via email to