diff --git a/development/FORMAT b/development/FORMAT index 7ca9e10372..314f9b0b20 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,6 +1,21 @@ LyX file-format changes ----------------------- +2006-08-14 Georg Baum + + * format incremented to 249: Unicode + + LyX documents are now always encoded in utf8. The value of + \inputencoding does now only determine the encoding of the created + LaTeX file. + Up to format 248 the value of \inputencoding did also determine the + encoding of the LyX file: + + \inputencoding LyX file encoding + auto as determined by the document language + default latin1 + everything else as determined by \inputencoding + 2006-07-03 Georg Baum * format incremented to 248: Basic booktabs support diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index 0161dc6afe..5ba2836d0c 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -73,7 +73,7 @@ format_relation = [("0_06", [200], generate_minor_versions("0.6" , 4)), ("1_2", [220], generate_minor_versions("1.2" , 4)), ("1_3", [221], generate_minor_versions("1.3" , 7)), ("1_4", range(222,246), generate_minor_versions("1.4" , 3)), - ("1_5", range(246,249), generate_minor_versions("1.5" , 0))] + ("1_5", range(246,250), generate_minor_versions("1.5" , 0))] def formats_list(): @@ -108,7 +108,9 @@ def trim_eol(line): return line[:-1] -def get_encoding(language, inputencoding): +def get_encoding(language, inputencoding, format): + if format > 248: + return "utf8" from lyx2lyx_lang import lang if inputencoding == "auto": return lang[language][3] @@ -224,7 +226,7 @@ class LyX_Base: self.format = self.read_format() self.language = get_value(self.header, "\\language", 0, default = "english") self.inputencoding = get_value(self.header, "\\inputencoding", 0, default = "auto") - self.encoding = get_encoding(self.language, self.inputencoding) + self.encoding = get_encoding(self.language, self.inputencoding, self.format) self.initial_version = self.read_version() # Second pass over header and preamble, now we know the file encoding @@ -246,7 +248,7 @@ class LyX_Base: self.set_version() self.set_format() if self.encoding == "auto": - self.encoding = get_encoding(self.language, self.encoding) + self.encoding = get_encoding(self.language, self.encoding, self.format) if self.preamble: i = find_token(self.header, '\\textclass', 0) + 1 diff --git a/lib/lyx2lyx/lyx_1_5.py b/lib/lyx2lyx/lyx_1_5.py index e26116ca13..2b055fcc46 100644 --- a/lib/lyx2lyx/lyx_1_5.py +++ b/lib/lyx2lyx/lyx_1_5.py @@ -21,6 +21,7 @@ import re from parser_tools import find_token, find_token_exact, find_tokens, find_end_of, get_value +from LyX import get_encoding #################################################################### @@ -217,13 +218,18 @@ def revert_booktabs(document): def convert_utf8(document): + document.encoding = "utf8" + + +def revert_utf8(document): i = find_token(document.header, "\\inputencoding", 0) if i == -1: - document.header.append("\\inputencoding utf-8") - else: - document.header[i] = "\\inputencoding utf-8" - document.inputencoding = "utf-8" - document.encoding = "utf-8" + document.header.append("\\inputencoding auto") + elif get_value(document.header, "\\inputencoding", i) == "utf8": + document.header[i] = "\\inputencoding auto" + document.inputencoding = get_value(document.header, "\\inputencoding", 0) + document.encoding = get_encoding(document.language, document.inputencoding, 248) + ## # Conversion hub @@ -232,11 +238,11 @@ def convert_utf8(document): supported_versions = ["1.5.0","1.5"] convert = [[246, []], [247, [convert_font_settings]], - [248, []] - # ,[xxx, [convert_utf8]] uncomment to support convertion to utf-8 - ] + [248, []], + [249, [convert_utf8]]] -revert = [[247, [revert_booktabs]], +revert = [[248, [revert_utf8]], + [247, [revert_booktabs]], [246, [revert_font_settings]], [245, [revert_framed]]] diff --git a/src/buffer.C b/src/buffer.C index fd50d05017..21240a0bea 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -146,7 +146,7 @@ extern BufferList bufferlist; namespace { -int const LYX_FORMAT = 248; +int const LYX_FORMAT = 249; } // namespace anon diff --git a/src/bufferparams.h b/src/bufferparams.h index d78692733a..4be55bdf4c 100644 --- a/src/bufferparams.h +++ b/src/bufferparams.h @@ -175,7 +175,15 @@ public: /// BranchList: BranchList & branchlist(); BranchList const & branchlist() const; - /// + /** + * The input encoding for LaTeX. This can be one of + * - auto: find out the input encoding from the used languages + * - default: Don't load the inputenc package and hope that it will + * work (unlikely) + * - any encoding supported by the inputenc package + * The encoding of the LyX file is always utf8 and has nothing to + * do with this setting. + */ std::string inputenc; /// std::string preamble;