fix surrogatepairs messing position of emotes to be removed (mismatch

between actual position, and position in unicode codepoints)
This commit is contained in:
hemirt 2018-11-15 21:11:50 +01:00
parent 9472283d76
commit 27eb2d8abc

View file

@ -183,9 +183,18 @@ MessagePtr TwitchMessageBuilder::build()
auto app = getApp();
const auto &phrases = app->ignores->phrases.getVector();
auto removeEmotesInRange =
[](int pos, int len,
[&message = this->originalMessage_](int pos, int len,
std::vector<std::tuple<int, EmotePtr, EmoteName>>
&twitchEmotes) mutable {
int emotePos = 0;
for(int i = 0; i < pos; ++i) {
++emotePos;
if (message.at(i).isLowSurrogate()) {
--emotePos;
}
}
pos = emotePos;
auto it =
std::partition(twitchEmotes.begin(), twitchEmotes.end(),
[pos, len](const auto &item) {