]> git.lyx.org Git - lyx.git/commitdiff
Small improvement for bug #7509 as suggested by JMarc
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 8 May 2011 08:23:42 +0000 (08:23 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 8 May 2011 08:23:42 +0000 (08:23 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38628 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/preamble.cpp
src/tex2lyx/tex2lyx.cpp
src/tex2lyx/tex2lyx.h

index 8de4f3b7150869634278e1fac1172333626bc564..df9462dbe97300e59258e706e002cf2331a1e877 100644 (file)
@@ -48,6 +48,7 @@ const char * const modules_placeholder = "\001modules\001";
 
 // needed to handle encodings with babel
 bool one_language = true;
+string h_inputencoding = "auto";
 
 namespace {
 
@@ -165,7 +166,6 @@ string h_textclass               = "article";
 string h_use_default_options     = "false";
 string h_options;
 string h_language                = "english";
-string h_inputencoding           = "auto";
 string h_font_roman              = "default";
 string h_font_sans               = "default";
 string h_font_typewriter         = "default";
@@ -517,7 +517,7 @@ void handle_package(Parser &p, string const & name, string const & opts,
        else if (name == "fontenc")
                 ;// ignore this
 
-       else if (name == "inputenc") {
+       else if (name == "inputenc" || name == "luainputenc") {
                // h_inputencoding is only set when there is not more than one
                // inputenc option because otherwise h_inputencoding must be
                // set to "auto" (the default encoding of the document language)
index 958e4a7eb37454249cd0d3c8af20be5d65d7c177..8d5e858885e31d27b29ed75a7259c3534fa4c4e5 100644 (file)
@@ -624,11 +624,22 @@ namespace {
  *  You must ensure that \p parentFilePath is properly set before calling
  *  this function!
  */
-void tex2lyx(idocstream & is, ostream & os, string const & encoding)
-{
+void tex2lyx(idocstream & is, ostream & os, string encoding)
+{
+       // Set a sensible default encoding.
+       // This is used until an encoding command is found.
+       // For child documents use the encoding of the master, else latin1,
+       // since latin1 does not cause an iconv error if the actual encoding
+       // is different (bug 7509).
+       if (encoding.empty()) {
+               if (h_inputencoding == "auto")
+                       encoding = "latin1";
+               else
+                       encoding = h_inputencoding;
+       }
+
        Parser p(is);
-       if (!encoding.empty())
-               p.setEncoding(encoding);
+       p.setEncoding(encoding);
        //p.dump();
 
        ostringstream ps;
index 6a3057f188f4f12d8a3f7d533c3d2e27cb9077da..f2bde2e8cb5fe1cd55608556d3aa723c2d6f9265 100644 (file)
@@ -52,6 +52,7 @@ extern std::string babel2lyx(std::string const & language);
 /// used packages with options
 extern std::map<std::string, std::vector<std::string> > used_packages;
 extern const char * const modules_placeholder;
+extern std::string h_inputencoding;
 
 /// in text.cpp
 std::string translate_len(std::string const &);