]> git.lyx.org Git - features.git/commitdiff
tex2lyx: consider utf8 default encoding in newer LaTeX
authorJuergen Spitzmueller <spitz@lyx.org>
Wed, 28 Dec 2022 10:42:59 +0000 (11:42 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Wed, 28 Dec 2022 11:32:39 +0000 (12:32 +0100)
src/tex2lyx/Preamble.cpp

index 98b95e8267aa0b6824983b2fa542e4f0182ce353..63e6c638147579322b0b235190ccfec6be26d108 100644 (file)
@@ -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();