From c237414cc6a3a62f62bf1cdfaa17173c30b9787c Mon Sep 17 00:00:00 2001 From: leha-bot Date: Sat, 21 Apr 2018 18:38:54 +0300 Subject: [PATCH] text_entity: Add enum for used Unicode codepoints It's better to use the named constants instead of magic character codes. --- Telegram/SourceFiles/ui/text/text_entity.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/ui/text/text_entity.cpp b/Telegram/SourceFiles/ui/text/text_entity.cpp index 5c68a9538..98fc1b516 100644 --- a/Telegram/SourceFiles/ui/text/text_entity.cpp +++ b/Telegram/SourceFiles/ui/text/text_entity.cpp @@ -24,6 +24,17 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "lang/lang_tag.h" namespace TextUtilities { + +// note: these names are taken from Unicode Specification. +// All spaces in this names are replaced to SwitchingCase, all dashes ('-') +// are replaced to underscore ('_') +enum UnicodePoints +{ + Left_PointingDoubleAngleQuotationMark = 171, + Right_PointingDoubleAngleQuotationMark = 187, + EmDash = 8212, +}; + namespace { QString ExpressionDomain() { @@ -2121,9 +2132,9 @@ void PrepareForSending(TextWithEntities &result, qint32 flags) { } if (cMessageFormatting()) { - ReplaceStringWithChar(qstr("--"), QChar(8212), result, true); - ReplaceStringWithChar(qstr("<<"), QChar(171), result); - ReplaceStringWithChar(qstr(">>"), QChar(187), result); + ReplaceStringWithChar(qstr("--"), QChar(EmDash), result, true); + ReplaceStringWithChar(qstr("<<"), QChar(Left_PointingDoubleAngleQuotationMark), result); + ReplaceStringWithChar(qstr(">>"), QChar(Right_PointingDoubleAngleQuotationMark), result); } if (cReplaceEmojis()) {