Skip to content

Commit

Permalink
WIP: emojos
Browse files Browse the repository at this point in the history
  • Loading branch information
askmeaboutlo0m committed Aug 21, 2023
1 parent 392fc59 commit da4f944
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/libclient/utils/html.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,21 @@ QString wrapEmoji(const QString &input, const QString &replacement)
// emoji, but it should hopefully be close enough for our use case.
// https://unicode.org/reports/tr51/#EBNF_and_Regex
static QRegularExpression re{
"(\\p{RI}\\p{RI}|\\p{Emoji}(\\p{EMod}|\\x{FE0F}\\x{20E3}?|[\\x{E0020}-"
"([aA]|\\p{RI}\\p{RI}|\\p{Emoji}(\\p{EMod}|\\x{FE0F}\\x{20E3}?|[\\x{E0020}-"
"\\x{E007E}]+\\x{E007F})?(\\x{200D}(\\p{RI}\\p{RI}|\\p{Emoji}(\\p{EMod}"
"|\\x{FE0F}\\x{20E3}?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?))*)+"};
QString s = input;
s.replace(re, replacement);
return s;
static bool errorShown = false;
if(re.isValid()) {
QString s = input;
s.replace(re, replacement);
return s + " also <span class=\"emoji\">🌈</span> <span class=\"emoji\">🫶🫡💀🔥🌘✅🫠</span>";
} else {
if(!errorShown) {
qWarning("Error compiling emoji regex: %s at position %d", qUtf8Printable(re.errorString()), int(re.patternErrorOffset()));
errorShown = true;
}
return input;
}
}

}

0 comments on commit da4f944

Please sign in to comment.