-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EmoteExtractor breaks on messages with emoji #259
Comments
Version tested on was |
Looking into it some, it appears Twitch uses multibyte encoding (UTF-16 maybe) and those are the indexes provided. The issue is the network traffic is decoded as UTF-8. You can use static string RemoveEmotes(ChatMessage msg)
{
StringBuilder parsed = new(msg.Message.Length);
StringInfo rawInfo = new(msg.Message);
int startIndex = 0;
foreach (Emote emote in msg.EmoteSet.Emotes.OrderBy(x => x.StartIndex))
{
parsed.Append(rawInfo.SubstringByTextElements(startIndex, emote.StartIndex - startIndex));
parsed.Replace(" ", " ");
startIndex = emote.EndIndex + 1;
}
if (startIndex < rawInfo.LengthInTextElements)
{
parsed.Append(rawInfo.SubstringByTextElements(startIndex));
parsed.Replace(" ", " ");
}
return parsed.ToString();
} |
Hampo
added a commit
to Hampo/TwitchLib.Client
that referenced
this issue
Dec 4, 2023
Fixed #260 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sent the message
One 😂 Two Kappa Three
in Twitch:Set a breakpoint on the first
Emote
in theEmoteSet
:You can see the
emote.Name
isKapp
instead ofKappa
. Best guess isEmoteExtractor
not respecting multi-byte characters, like emoji.The text was updated successfully, but these errors were encountered: