From 32b5d253d1b7e36c6389728039e45d97e8cca85e Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Wed, 28 Dec 2022 11:42:59 +0100 Subject: [PATCH] tex2lyx: consider utf8 default encoding in newer LaTeX --- src/tex2lyx/Preamble.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index 98b95e8267..63e6c63814 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -17,6 +17,7 @@ #include "tex2lyx.h" #include "Encoding.h" +#include "LaTeXPackages.h" #include "LayoutFile.h" #include "Lexer.h" #include "TextClass.h" @@ -757,7 +758,11 @@ void Preamble::handle_package(Parser &p, string const & name, registerAutomaticallyLoadedPackage("fontspec"); if (h_inputencoding == "auto-legacy") p.setEncoding("UTF-8"); - } + } else if (h_inputencoding == "auto-legacy" + && LaTeXPackages::isAvailableAtLeastFrom("LaTeX", 2018, 04)) + // As of LaTeX 2018/04/01, utf8 is the default input encoding + // So use that if no inputencoding is set + h_inputencoding = "utf8"; // vector of all options for easier parsing and // skipping @@ -1694,8 +1699,10 @@ void Preamble::handle_package(Parser &p, string const & name, cerr << "Unknown encoding " << encoding << ". Ignoring." << std::endl; } else { - if (!enc->unsafe() && options.size() == 1 && one_language == true) + if (!enc->unsafe() && options.size() == 1 && one_language == true) { h_inputencoding = enc->name(); + docencoding = enc->iconvName(); + } p.setEncoding(enc->iconvName()); } options.clear(); -- 2.39.5