From: Enrico Forestieri Date: Sat, 14 Jan 2012 15:06:40 +0000 (+0000) Subject: Refine fix for bug #7800. Don't use \inputencoding if the strings can be X-Git-Tag: 2.0.3~79 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=dac462c96b38a77185f19e5de1505c897884cabb;p=features.git 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 --- diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index aaae007564..780fae5ede 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -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; diff --git a/src/Layout.cpp b/src/Layout.cpp index dd468258e3..1606977779 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -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); } diff --git a/status.20x b/status.20x index 0652072986..181a3bdf54 100644 --- a/status.20x +++ b/status.20x @@ -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