mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-18 05:37:11 +00:00
Avoid \inputencoding altogether if the buffer encoding permits
(part of bug #7800). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40612 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4026c0dccd
commit
76c376c427
@ -1156,6 +1156,17 @@ docstring const getFloatI18nPreamble(docstring const & type,
|
|||||||
Encoding const & enc, bool const polyglossia,
|
Encoding const & enc, bool const polyglossia,
|
||||||
bool const unicode)
|
bool const unicode)
|
||||||
{
|
{
|
||||||
|
// Check whether name can be encoded in the buffer encoding
|
||||||
|
bool encodable = true;
|
||||||
|
if (!unicode) {
|
||||||
|
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())
|
docstring const language = polyglossia ? from_ascii(lang->polyglossia())
|
||||||
: from_ascii(lang->babel());
|
: from_ascii(lang->babel());
|
||||||
docstring const langenc = from_ascii(lang->encoding()->iconvName());
|
docstring const langenc = from_ascii(lang->encoding()->iconvName());
|
||||||
@ -1163,7 +1174,7 @@ docstring const getFloatI18nPreamble(docstring const & type,
|
|||||||
docstring const bufenc = from_ascii(enc.iconvName());
|
docstring const bufenc = from_ascii(enc.iconvName());
|
||||||
docstring const s1 = docstring(1, 0xF0000);
|
docstring const s1 = docstring(1, 0xF0000);
|
||||||
docstring const s2 = docstring(1, 0xF0001);
|
docstring const s2 = docstring(1, 0xF0001);
|
||||||
docstring const translated = (unicode || langenc == bufenc) ? name
|
docstring const translated = encodable ? name
|
||||||
: from_ascii("\\inputencoding{") + texenc + from_ascii("}")
|
: from_ascii("\\inputencoding{") + texenc + from_ascii("}")
|
||||||
+ s1 + langenc + s2 + name + s1 + bufenc + s2;
|
+ s1 + langenc + s2 + name + s1 + bufenc + s2;
|
||||||
|
|
||||||
|
@ -891,10 +891,20 @@ docstring const i18npreamble(Language const * lang, Encoding const & enc,
|
|||||||
smatch sub;
|
smatch sub;
|
||||||
while (regex_search(preamble, sub, reg)) {
|
while (regex_search(preamble, sub, reg)) {
|
||||||
string const key = sub.str(1);
|
string const key = sub.str(1);
|
||||||
string translated = to_utf8(lang->translateLayout(key));
|
docstring const name = lang->translateLayout(key);
|
||||||
if (!unicode && langenc != bufenc)
|
// Check whether name can be encoded in the buffer encoding
|
||||||
translated = "\\inputencoding{" + texenc + "}"
|
bool encodable = true;
|
||||||
+ s1 + langenc + s2 + translated
|
if (!unicode) {
|
||||||
|
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;
|
+ s1 + bufenc + s2;
|
||||||
preamble = subst(preamble, sub.str(), translated);
|
preamble = subst(preamble, sub.str(), translated);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user