diff --git a/ui/text/text.cpp b/ui/text/text.cpp index afaf7db..c3d20dc 100644 --- a/ui/text/text.cpp +++ b/ui/text/text.cpp @@ -1822,6 +1822,9 @@ bool IsDiacritic(QChar ch) { // diacritic and variation selectors } bool IsReplacedBySpace(QChar ch) { + // Those symbols are replaced by space on the Telegram server, + // so we replace them as well, for sent / received consistency. + // // \xe2\x80[\xa8 - \xac\xad] // 8232 - 8237 // QString from1 = QString::fromUtf8("\xe2\x80\xa8"), to1 = QString::fromUtf8("\xe2\x80\xad"); // \xcc[\xb3\xbf\x8a] // 819, 831, 778 diff --git a/ui/text/text_parser.cpp b/ui/text/text_parser.cpp index 4bb48b0..8396605 100644 --- a/ui/text/text_parser.cpp +++ b/ui/text/text_parser.cpp @@ -81,6 +81,16 @@ constexpr auto kMaxDiacAfterSymbol = 2; && (font->f.family() == qstr("Open Sans")); } +[[nodiscard]] bool IsDiacriticAllowedAfter(QChar ch) { + const auto code = ch.unicode(); + const auto category = ch.category(); + return (code > 32) + && (category != QChar::Other_Control) + && (category != QChar::Other_Format) + && (category != QChar::Other_PrivateUse) + && (category != QChar::Other_NotAssigned); +} + } // namespace Parser::StartedEntity::StartedEntity(TextBlockFlags flags) @@ -564,7 +574,7 @@ void Parser::parseCurrentChar() { createBlock(-_emojiLookback); } _t->_text.push_back(_ch); - _allowDiacritic = true; + _allowDiacritic = IsDiacriticAllowedAfter(_ch); } if (!isDiacritic) { _diacritics = 0;