refactor: move zero width replacement to a function (#5594)
This commit is contained in:
@@ -7,6 +7,18 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QUuid>
|
||||
|
||||
namespace {
|
||||
|
||||
const QString ZERO_WIDTH_JOINER = QStringLiteral("\u200D");
|
||||
|
||||
// Note: \U requires /utf-8 for MSVC
|
||||
// See https://mm2pl.github.io/emoji_rfc.pdf
|
||||
const QRegularExpression ESCAPE_TAG_REGEX(
|
||||
QStringLiteral("(?<!\U000E0002)\U000E0002"),
|
||||
QRegularExpression::UseUnicodePropertiesOption);
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
namespace helpers::detail {
|
||||
@@ -283,4 +295,10 @@ bool compareEmoteStrings(const QString &a, const QString &b)
|
||||
return k < 0;
|
||||
}
|
||||
|
||||
QString unescapeZeroWidthJoiner(QString escaped)
|
||||
{
|
||||
escaped.replace(ESCAPE_TAG_REGEX, ZERO_WIDTH_JOINER);
|
||||
return escaped;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user