diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp index 52fa0cf0fa..e911f0babf 100644 --- a/src/mathed/MathExtern.cpp +++ b/src/mathed/MathExtern.cpp @@ -1421,11 +1421,46 @@ void write(MathData const & dat, WriteStream & wi) void writeString(docstring const & s, WriteStream & os) { - if (!os.latex() || os.lockedMode()) { + if (!os.latex()) { os << (os.asciiOnly() ? escape(s) : s); return; } + if (os.lockedMode()) { + bool space; + docstring cmd; + for (char_type c : s) { + try { + Encodings::latexMathChar(c, true, os.encoding(), cmd, space); + os << cmd; + os.pendingSpace(space); + } catch (EncodingException const & e) { + switch (os.output()) { + case WriteStream::wsDryrun: { + os << "<" << _("LyX Warning: ") + << _("uncodable character") << " '"; + os << docstring(1, e.failed_char); + os << "'>"; + break; + } + case WriteStream::wsPreview: { + // indicate the encoding error by a boxed '?' + os << "{\\fboxsep=1pt\\fbox{?}}"; + LYXERR0("Uncodable character" << " '" + << docstring(1, e.failed_char) + << "'"); + break; + } + case WriteStream::wsDefault: + default: + // throw again + throw(e); + } + } + } + return; + } + docstring::const_iterator cit = s.begin(); docstring::const_iterator end = s.end(); diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index 539b1a3f02..868b920ebe 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -2077,7 +2077,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, Encodings::MATH_CMD | Encodings::TEXT_CMD, is_combining, termination); } - if (c) { + if (c && buf->params().encoding().encodable(c)) { if (termination) { if (nextToken().cat() == catBegin) { getToken(); diff --git a/status.23x b/status.23x index 964a5397a5..dbd63f04da 100644 --- a/status.23x +++ b/status.23x @@ -54,6 +54,10 @@ Avoid using text mode for unicode symbols representable in math mode (bug 9616). - Avoid superfluous braces in the optional argument of a macro (bug 11552). +- Do not replace a latex command with the corresponding symbol in the + unicodesymbols file, unless it can be encoded in the document encoding + (bug 11586). + * USER INTERFACE