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());
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;
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);
}
- 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