]> git.lyx.org Git - lyx.git/commitdiff
Don't switch encodings to/from CJK if the document encoding is using the CJK package.
authorGünter Milde <milde@lyx.org>
Thu, 7 Feb 2019 21:07:59 +0000 (22:07 +0100)
committerGünter Milde <milde@lyx.org>
Sat, 9 Feb 2019 19:42:24 +0000 (20:42 +0100)
Also, since we return earlier if the document encoding is an utf8-variant
since fc0ab1283, the wrapper around "setEncoding" is no longer required.

src/output_latex.cpp

index 23068de13186e7875d982c04aec59bee510e380c..4e637ee8056bad4385350191f39c4f3677c143a9 100644 (file)
@@ -1260,7 +1260,8 @@ void TeXOnePar(Buffer const & buf,
        // if this is a CJK-paragraph and the next isn't, close CJK
        // also if the next paragraph is a multilingual environment (because of nesting)
        if (nextpar
-               && (state->open_encoding_ == CJK && bparams.encoding().iconvName() != "UTF-8")
+               && (state->open_encoding_ == CJK && bparams.encoding().iconvName() != "UTF-8"
+                       && bparams.encoding().package() != Encoding::CJK )
                && (nextpar_language->encoding()->package() != Encoding::CJK
                   || (nextpar->layout().isEnvironment() && nextpar->isMultiLingual(bparams)))
                // inbetween environments, CJK has to be closed later (nesting!)
@@ -1610,8 +1611,8 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
        bool const from_to_cjk =
                ((oldEnc.package() == Encoding::CJK && newEnc.package() != Encoding::CJK)
                 || (oldEnc.package() != Encoding::CJK && newEnc.package() == Encoding::CJK))
-               && (bparams.encoding().name() != "utf8-cjk" && bparams.encoding().name() != "utf8")
-               && bparams.encoding().package() != Encoding::CJK;
+               && bparams.encoding().iconvName() != "UTF8"
+               && bparams.encoding().package() != Encoding::CJK;
        if (!force && !from_to_cjk
            && ((bparams.inputenc != "auto" && bparams.inputenc != "default") || moving_arg))
                return make_pair(false, 0);
@@ -1631,14 +1632,12 @@ pair<bool, int> switchEncoding(odocstream & os, BufferParams const & bparams,
        if (oldEnc.package() == Encoding::none || newEnc.package() == Encoding::none)
                return make_pair(false, 0);
 
-       // change encoding (not required with UTF8)
-       if (bparams.encoding().iconvName() != "UTF-8") {
-               LYXERR(Debug::LATEX, "Changing LaTeX encoding from "
-                          << oldEnc.name() << " to " << newEnc.name());
-               os << setEncoding(newEnc.iconvName());
-               if (bparams.inputenc == "default")
-                 return make_pair(true, 0);
-       }
+       // change encoding
+       LYXERR(Debug::LATEX, "Changing LaTeX encoding from "
+                  << oldEnc.name() << " to " << newEnc.name());
+       os << setEncoding(newEnc.iconvName());
+       if (bparams.inputenc == "default")
+         return make_pair(true, 0);
 
        docstring const inputenc_arg(from_ascii(newEnc.latexName()));
        OutputState * state = getOutputState();