Small improvement for bug #7509 as suggested by JMarc

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@38643 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2011-05-08 15:40:45 +00:00
parent 356ef38a8c
commit 6da499d3f6
4 changed files with 20 additions and 5 deletions

View File

@ -48,6 +48,7 @@ const char * const modules_placeholder = "\001modules\001";
// needed to handle encodings with babel // needed to handle encodings with babel
bool one_language = true; bool one_language = true;
string h_inputencoding = "auto";
namespace { namespace {
@ -165,7 +166,6 @@ string h_textclass = "article";
string h_use_default_options = "false"; string h_use_default_options = "false";
string h_options; string h_options;
string h_language = "english"; string h_language = "english";
string h_inputencoding = "auto";
string h_font_roman = "default"; string h_font_roman = "default";
string h_font_sans = "default"; string h_font_sans = "default";
string h_font_typewriter = "default"; string h_font_typewriter = "default";
@ -517,7 +517,7 @@ void handle_package(Parser &p, string const & name, string const & opts,
else if (name == "fontenc") else if (name == "fontenc")
;// ignore this ;// ignore this
else if (name == "inputenc") { else if (name == "inputenc" || name == "luainputenc") {
// h_inputencoding is only set when there is not more than one // h_inputencoding is only set when there is not more than one
// inputenc option because otherwise h_inputencoding must be // inputenc option because otherwise h_inputencoding must be
// set to "auto" (the default encoding of the document language) // set to "auto" (the default encoding of the document language)

View File

@ -624,10 +624,21 @@ namespace {
* You must ensure that \p parentFilePath is properly set before calling * You must ensure that \p parentFilePath is properly set before calling
* this function! * this function!
*/ */
void tex2lyx(idocstream & is, ostream & os, string const & encoding) void tex2lyx(idocstream & is, ostream & os, string encoding)
{ {
// Set a sensible default encoding.
// This is used until an encoding command is found.
// For child documents use the encoding of the master, else latin1,
// since latin1 does not cause an iconv error if the actual encoding
// is different (bug 7509).
if (encoding.empty()) {
if (h_inputencoding == "auto")
encoding = "latin1";
else
encoding = h_inputencoding;
}
Parser p(is); Parser p(is);
if (!encoding.empty())
p.setEncoding(encoding); p.setEncoding(encoding);
//p.dump(); //p.dump();

View File

@ -52,6 +52,7 @@ extern std::string babel2lyx(std::string const & language);
/// used packages with options /// used packages with options
extern std::map<std::string, std::vector<std::string> > used_packages; extern std::map<std::string, std::vector<std::string> > used_packages;
extern const char * const modules_placeholder; extern const char * const modules_placeholder;
extern std::string h_inputencoding;
/// in text.cpp /// in text.cpp
std::string translate_len(std::string const &); std::string translate_len(std::string const &);

View File

@ -58,6 +58,9 @@ What's new
- Fix validation problem with user macros (bug #7525). - Fix validation problem with user macros (bug #7525).
- Improve import of LaTeX documents with non-ASCII contents before loading
the inputenc package (bug #7509).
* USER INTERFACE * USER INTERFACE