]> git.lyx.org Git - features.git/commitdiff
Respect the encoding passed to tex2lyx on the command line.
authorJulien Rioux <jrioux@lyx.org>
Sat, 19 Jan 2013 19:02:33 +0000 (20:02 +0100)
committerJulien Rioux <jrioux@lyx.org>
Tue, 22 Jan 2013 23:25:00 +0000 (00:25 +0100)
Fixup for #8218, fixes #8518.

src/tex2lyx/Preamble.cpp
src/tex2lyx/text.cpp

index 4e976ec13f4586428dd68d2caaa02bef3195a32f..61ce6b87e870d18cc5e2be00c1e5fe7463c697cf 100644 (file)
@@ -727,11 +727,19 @@ void Preamble::handle_package(Parser &p, string const & name,
                        handle_opt(options, known_languages, h_language);
                        // translate the babel name to a LyX name
                        h_language = babel2lyx(h_language);
-                       // for Japanese we assume EUC-JP as encoding
-                       // but we cannot determine the exact encoding and thus output also a note
                        if (h_language == "japanese") {
-                               h_inputencoding = "euc";
-                               p.setEncoding("EUC-JP");
+                               // For Japanese, the encoding isn't indicated in the source
+                               // file, and there's really not much we can do. We could
+                               // 1) offer a list of possible encodings to choose from, or
+                               // 2) determine the encoding of the file by inspecting it.
+                               // For the time being, we leave the encoding alone so that
+                               // we don't get iconv errors when making a wrong guess, and
+                               // we will output a note at the top of the document
+                               // explaining what to do.
+                               Encoding const * const enc = encodings.fromIconvName(
+                                       p.getEncoding(), Encoding::japanese, true);
+                               if (enc)
+                                       h_inputencoding = enc->name();
                                is_nonCJKJapanese = true;
                                // in this case babel can be removed from the preamble
                                registerAutomaticallyLoadedPackage("babel");
index 9d90c2d2e055b8fb4e78a9f114e913905d2bdf7e..51e413bafa7db8c13317d623515fd25e81e766b8 100644 (file)
@@ -2218,10 +2218,13 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                   << "Important information:\n"
                   << "\\end_layout\n\n"
                   << "\\begin_layout Plain Layout\n"
-                  << "This document is in Japanese (non-CJK).\n"
-                  << " It was therefore impossible for tex2lyx to determine the correct encoding."
-                  << " The encoding EUC-JP was assumed. If this is incorrect, please set the correct"
-                  << " encoding in the document settings.\n"
+                  << "The original LaTeX source for this document is in Japanese (pLaTeX).\n"
+                  << " It was therefore impossible for tex2lyx to determine the correct encoding.\n"
+                  << " The iconv encoding " << p.getEncoding() << " was used.\n"
+                  << " If this is incorrect, you must run the tex2lyx program on the command line\n"
+                  << " and specify the encoding using the -e command-line switch.\n"
+                  << " In addition, you might want to double check that the desired output encoding\n"
+                  << " is correctly selected in Document > Settings > Language.\n"
                   << "\\end_layout\n";
                end_inset(os);
                is_nonCJKJapanese = false;