]> git.lyx.org Git - features.git/commitdiff
Refine fix for bug #7800. Don't use \inputencoding if the strings can be
authorEnrico Forestieri <forenr@lyx.org>
Sat, 14 Jan 2012 15:06:40 +0000 (15:06 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Sat, 14 Jan 2012 15:06:40 +0000 (15:06 +0000)
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

src/LaTeXFeatures.cpp
src/Layout.cpp
status.20x

index aaae0075641fe089dae19983b22a61978db9dd00..780fae5edec0b220e8bd4e77948d8a7e5fd687ef 100644 (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;
 
index dd468258e3c05fae0a88f5e1f19bbcf1b2a5c28d..16069777791fb438389db94c03b3efabce00f737 100644 (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);
        }
index 065207298652ab292896ebdebea9f6dc289fa239..181a3bdf542cf6242ae5f0108d230d655cb83b30 100644 (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