diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index b5650e270b..636d4b27f7 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -23,12 +23,7 @@ import unicodedata import sys, os from parser_tools import find_token, find_end_of, find_tokens, get_value - -# Provide support for both python 2 and 3 -PY2 = sys.version_info[0] == 2 -if not PY2: - unichr = chr -# End of code to support for both python 2 and 3 +from unicode_symbols import read_unicodesymbols #################################################################### # Private helper functions @@ -151,9 +146,18 @@ def set_option(document, m, option, value): return l -# FIXME: Use the version in unicode_symbols.py which has some bug fixes -def read_unicodesymbols(): +# FIXME: Remove this function if the version imported from unicode_symbols works. +# This function was the predecessor from that function, that in the meanwhile got +# new fixes. +def read_unicodesymbols2(): " Read the unicodesymbols list of unicode characters and corresponding commands." + + # Provide support for both python 2 and 3 + PY2 = sys.version_info[0] == 2 + if not PY2: + unichr = chr + # End of code to support for both python 2 and 3 + pathname = os.path.abspath(os.path.dirname(sys.argv[0])) fp = open(os.path.join(pathname.strip('lyx2lyx'), 'unicodesymbols')) spec_chars = [] diff --git a/lib/lyx2lyx/unicode_symbols.py b/lib/lyx2lyx/unicode_symbols.py index f24f3a9187..d9eeff9683 100644 --- a/lib/lyx2lyx/unicode_symbols.py +++ b/lib/lyx2lyx/unicode_symbols.py @@ -29,7 +29,12 @@ if not PY2: def read_unicodesymbols(): " Read the unicodesymbols list of unicode characters and corresponding commands." pathname = os.path.abspath(os.path.dirname(sys.argv[0])) - fp = open(os.path.join(pathname.strip('lyx2lyx'), 'unicodesymbols')) + filename = os.path.join(pathname.strip('lyx2lyx'), 'unicodesymbols') + + # For python 3+ we have to specify the encoding for those systems + # where the default is not UTF-8 + fp = open(filename, encoding="utf8") if (not PY2) else open(filename) + spec_chars = [] # A backslash, followed by some non-word character, and then a character # in brackets. The idea is to check for constructs like: \"{u}, which is how