]> git.lyx.org Git - features.git/commitdiff
Change lyx2lyx conversion and LaTeX export of documents with
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 13 Jan 2007 14:36:54 +0000 (14:36 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 13 Jan 2007 14:36:54 +0000 (14:36 +0000)
\inputencoding default

* src/paragraph_pimpl.C
(isEncoding): Explain why bparams.inputenc == "default" is ignored

* src/bufferparams.C
(BufferParams::encoding): Determine the encoding from the language
for inputenc == "default"

* src/buffer.h
(writeLaTeXSource): Mention inputenc == "default" in documentation

* src/bufferparams.h
(inputenc): Update documentation of "default"

* src/output_latex.C
(switchEncoding): Switch the encoding also for inputenc == "default",
but don't output \inputencoding commands in that case

* lib/lyx2lyx/LyX.py
(get_encoding): Determine the encoding from the language for
inputencoding == "default"

* lib/lyx2lyx/lyx_1_5.py
(convert_multiencoding): ditto

* development/FORMAT: Update documentation of \inputencoding default

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16667 a592a061-630c-0410-9148-cb99ea01b6c8

development/FORMAT
lib/lyx2lyx/LyX.py
lib/lyx2lyx/lyx_1_5.py
src/buffer.h
src/bufferparams.C
src/bufferparams.h
src/output_latex.C
src/paragraph_pimpl.C

index 75b69a8adc1711cf4c0466d65849ae0f38b07d77..8a54eea112adeb8638b5440c70c396c4b26625d9 100644 (file)
@@ -78,11 +78,14 @@ LyX file-format changes
        encoding of the LyX file:
 
        \inputencoding       LyX file encoding
-       auto                 as determined by the document language(s)
-       default              unspecified 8bit (treated as latin1 internally,
-                            see comment in bufferparams.h)
+       auto                 as determined by the document and character
+                            languages
+       default              ditto
        everything else      as determined by \inputencoding
 
+       The difference between auto and default is only the LaTeX output:
+       auto causes loading of the inputenc package, default does not.
+
 2006-07-03  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
 
        * format incremented to 248: Basic booktabs support
index a21223dac00d6d06c05ec272004c6cb936135cdc..b0bdbdbee84868639b07545f358e7955ff4ea1d3 100644 (file)
@@ -112,9 +112,9 @@ def get_encoding(language, inputencoding, format):
     if format > 248:
         return "utf8"
     from lyx2lyx_lang import lang
-    if inputencoding == "auto":        
+    if inputencoding == "auto" or inputencoding == "default":
         return lang[language][3]
-    if inputencoding == "default" or inputencoding == "":
+    if inputencoding == "":
         return "latin1"
     # python does not know the alias latin9
     if inputencoding == "latin9":
index dcd600d00dd94eee30572fffd26a26a949d6ead8..8918fb386fc07c44223bddfd43d2505f744d118e 100644 (file)
@@ -219,10 +219,11 @@ def revert_booktabs(document):
 
 def convert_multiencoding(document, forward):
     """ Fix files with multiple encodings.
-Files with an inputencoding of "auto" and multiple languages where at least
-two languages have different default encodings are encoded in multiple
-encodings for file formats < 249. These files are incorrectly read and
-written (as if the whole file was in the encoding of the main language).
+Files with an inputencoding of "auto" or "default" and multiple languages
+where at least two languages have different default encodings are encoded
+in multiple encodings for file formats < 249. These files are incorrectly
+read and written (as if the whole file was in the encoding of the main
+language).
 
 This function
 - converts from fake unicode values to true unicode if forward is true, and
@@ -234,7 +235,7 @@ necessary parsing in modern formats than in ancient ones.
 """
     encoding_stack = [document.encoding]
     lang_re = re.compile(r"^\\lang\s(\S+)")
-    if document.inputencoding == "auto":
+    if document.inputencoding == "auto" or document.inputencoding == "default":
         for i in range(len(document.body)):
             result = lang_re.match(document.body[i])
             if result:
index 98d7669eae4a6de0f6e7b5e00948ce7adc265aac..66f5f7901d46b9f4e29846165a076536849d8a3a 100644 (file)
@@ -153,11 +153,12 @@ public:
                           bool output_preamble = true,
                           bool output_body = true);
        /** Export the buffer to LaTeX.
-           If \p os is a file stream, and params().inputenc == "auto", and
-           the buffer contains text in different languages with more than
-           one encoding, then this method will change the encoding
-           associated to \p os. Therefore you must not call this method with
-           a string stream if the output is supposed to go to a file. \code
+           If \p os is a file stream, and params().inputenc is "auto" or
+           "default", and the buffer contains text in different languages
+           with more than one encoding, then this method will change the
+           encoding associated to \p os. Therefore you must not call this
+           method with a string stream if the output is supposed to go to a
+           file. \code
            odocfstream ofs;
            ofs.open("test.tex");
            writeLaTeXSource(ofs, ...);
index 959d087b79e8184aa0e00207a26f790a3f47b985..dff424a9af00d7cb4d0b5cae3fedd22f7e08c9f9 100644 (file)
@@ -1466,20 +1466,14 @@ string const BufferParams::loadFonts(LaTeXFeatures & features, string const & rm
 
 Encoding const & BufferParams::encoding() const
 {
-       if (inputenc == "auto")
+       if (inputenc == "auto" || inputenc == "default")
                return *(language->encoding());
-       Encoding const * const enc = (inputenc == "default") ?
-               encodings.getFromLyXName("iso8859-1") :
+       Encoding const * const enc =
                encodings.getFromLaTeXName(inputenc);
        if (enc)
                return *enc;
-       if (inputenc == "default")
-               lyxerr << "Could not find iso8859-1 encoding for inputenc "
-                         "value `default'. Using inputenc `auto' instead."
-                      << endl;
-       else
-               lyxerr << "Unknown inputenc value `" << inputenc
-                      << "'. Using `auto' instead." << endl;
+       lyxerr << "Unknown inputenc value `" << inputenc
+              << "'. Using `auto' instead." << endl;
        return *(language->encoding());
 }
 
index 28599a93ac10b78bb544a08ee53d2e582676013e..99d40077652b3ca94e49323c9f0c8a7ecc3e1a65 100644 (file)
@@ -178,15 +178,18 @@ public:
        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). The encoding is an unspecified 8bit encoding,
-        *   the interpretation is up to the LaTeX compiler. Because we need
-        *   a rule how to create this from our internal UCS4 encoded
-        *   document contents we treat this as latin1 internally.
+        * - \c auto: find out the input encoding from the used languages
+        * - \c default: ditto
         * - any encoding supported by the inputenc package
         * The encoding of the LyX file is always utf8 and has nothing to
         * do with this setting.
+        * The difference between \c auto and \c default is that \c auto also
+        * causes loading of the inputenc package, while \c default does not.
+        * \c default will not work unless the user takes additional measures
+        * (such as using special environments like the CJK environment from
+        * CJK.sty).
+        * \c default can be seen as an unspecified 8bit encoding, since LyX
+        * does not interpret it in any way apart from display on screen.
         */
        std::string inputenc;
        /// The main encoding used by this buffer for LaTeX output.
index 59a69511c553562698f785b438b9b3d1c97a0387..383da47b2bbd82c85e3e16ae22c35b7da0f5b9b8 100644 (file)
@@ -600,15 +600,18 @@ int switchEncoding(odocstream & os, BufferParams const & bparams,
        // ignore switches from/to tis620-0 encoding here. This does of
        // course only work as long as the non-thai text contains ASCII
        // only, but it is the best we can do.
-       if (bparams.inputenc == "auto" && oldEnc.name() != newEnc.name() &&
+       if ((bparams.inputenc == "auto" || bparams.inputenc == "default") &&
+           oldEnc.name() != newEnc.name() &&
            oldEnc.name() != "tis620-0" && newEnc.name() != "tis620-0") {
                lyxerr[Debug::LATEX] << "Changing LaTeX encoding from "
                                     << oldEnc.name() << " to "
                                     << newEnc.name() << endl;
                os << setEncoding(newEnc.iconvName());
-               docstring const inputenc(from_ascii(newEnc.latexName()));
-               os << "\\inputencoding{" << inputenc << '}';
-               return 16 + inputenc.length();
+               if (bparams.inputenc != "default") {
+                       docstring const inputenc(from_ascii(newEnc.latexName()));
+                       os << "\\inputencoding{" << inputenc << '}';
+                       return 16 + inputenc.length();
+               }
        }
        return 0;
 }
index 1a8cbfef35ce704358d6cb1a6e7b335ede563f08..0a3b64715bba2ac50d3544c551419f5a16ed9136 100644 (file)
@@ -62,6 +62,10 @@ size_t const phrases_nr = sizeof(special_phrases)/sizeof(special_phrase);
 bool isEncoding(BufferParams const & bparams, LyXFont const & font,
                string const & encoding)
 {
+       // We do ignore bparams.inputenc == "default" here because characters
+       // in this encoding could be treated by TeX as something different,
+       // e.g. if they are inside a CJK environment. See also
+       // http://bugzilla.lyx.org/show_bug.cgi?id=3043.
        return (bparams.inputenc == encoding
                || (bparams.inputenc == "auto"
                    && font.language()->encoding()->latexName() == encoding));