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");
<< "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;