mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
Ignore invisible characters while checking if text have only emojis.
This commit is contained in:
parent
0f5c37088e
commit
b3900c9105
2 changed files with 6 additions and 1 deletions
|
|
@ -696,6 +696,10 @@ bool Utils::codepointIsEmoji(uint code){
|
|||
(code >= 0x1f000 && code <= 0x1faff) || code == 0x200d || code == 0xfe0f;
|
||||
}
|
||||
|
||||
bool Utils::codepointIsVisible(uint code) {
|
||||
return code > 0x00020;
|
||||
}
|
||||
|
||||
QString Utils::encodeEmojiToQmlRichFormat(const QString &body){
|
||||
QString fmtBody = "";
|
||||
QVector<uint> utf32_string = body.toUcs4();
|
||||
|
|
@ -726,7 +730,7 @@ bool Utils::isOnlyEmojis(const QString& text){
|
|||
if(text.isEmpty()) return false;
|
||||
QVector<uint> utf32_string = text.toUcs4();
|
||||
for (auto &code : utf32_string)
|
||||
if( !Utils::codepointIsEmoji(code))
|
||||
if(codepointIsVisible(code) && !Utils::codepointIsEmoji(code))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ public:
|
|||
Q_INVOKABLE static QPoint getCursorPosition();
|
||||
Q_INVOKABLE static QString getFileChecksum(const QString& filePath);
|
||||
static bool codepointIsEmoji(uint code);
|
||||
static bool codepointIsVisible(uint code);
|
||||
Q_INVOKABLE static bool isOnlyEmojis(const QString& text);
|
||||
Q_INVOKABLE static QString encodeEmojiToQmlRichFormat(const QString &body);
|
||||
Q_INVOKABLE static QString encodeTextToQmlRichFormat(const QString& text, const QVariantMap& options = QVariantMap());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue