From: Julien Rioux Date: Sat, 19 Jan 2013 19:02:33 +0000 (+0100) Subject: Respect the encoding passed to tex2lyx on the command line. X-Git-Tag: 2.1.0beta1~878 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=0601336c243e1c333ec9607fe05c7d40e7b50485;p=features.git Respect the encoding passed to tex2lyx on the command line. Fixup for #8218, fixes #8518. --- diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index 4e976ec13f..61ce6b87e8 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -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"); diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 9d90c2d2e0..51e413bafa 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -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;