Refine fix for bug #7800. Don't use \inputencoding if the strings can be

encoded in the current buffer encoding.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@40614 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2012-01-14 15:06:40 +00:00
parent 87ecdb2a9e
commit dac462c96b
3 changed files with 25 additions and 5 deletions

View File

@ -1126,6 +1126,15 @@ docstring const getFloatI18nPreamble(docstring const & type,
docstring const & name, Language const * lang,
Encoding const & enc, bool const polyglossia)
{
// Check whether name can be encoded in the buffer encoding
bool encodable = true;
for (size_t i = 0; i < name.size(); ++i) {
if (enc.latexChar(name[i], true)[0] != name[i]) {
encodable = false;
break;
}
}
docstring const language = polyglossia ? from_ascii(lang->polyglossia())
: from_ascii(lang->babel());
docstring const langenc = from_ascii(lang->encoding()->iconvName());
@ -1133,7 +1142,7 @@ docstring const getFloatI18nPreamble(docstring const & type,
docstring const bufenc = from_ascii(enc.iconvName());
docstring const s1 = docstring(1, 0xF0000);
docstring const s2 = docstring(1, 0xF0001);
docstring const translated = (langenc == bufenc) ? name
docstring const translated = encodable ? name
: from_ascii("\\inputencoding{") + texenc + from_ascii("}")
+ s1 + langenc + s2 + name + s1 + bufenc + s2;

View File

@ -892,10 +892,18 @@ docstring const i18npreamble(Language const * lang, Encoding const & enc,
smatch sub;
while (regex_search(preamble, sub, reg)) {
string const key = sub.str(1);
string translated = to_utf8(lang->translateLayout(key));
if (langenc != bufenc)
translated = "\\inputencoding{" + texenc + "}"
+ s1 + langenc + s2 + translated
docstring const name = lang->translateLayout(key);
// Check whether name can be encoded in the buffer encoding
bool encodable = true;
for (size_t i = 0; i < name.size(); ++i) {
if (enc.latexChar(name[i], true)[0] != name[i]) {
encodable = false;
break;
}
}
string const translated = encodable ? to_utf8(name)
: "\\inputencoding{" + texenc + "}"
+ s1 + langenc + s2 + to_utf8(name)
+ s1 + bufenc + s2;
preamble = subst(preamble, sub.str(), translated);
}

View File

@ -125,6 +125,9 @@ What's new
- Fix dvips paper size arguments for presentations (beamer etc) (bug 7013).
- Do not use \inputencoding for translated names of theorem-like environments
if they can be actually encoded in the chosen document encoding (bug 7800).
* TEX2LYX