mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-22 10:55:15 -04:00
Fix Twemoji URLs with ZWJs being generated incorrectly (#865)
This commit is contained in:
parent
aca94ddccb
commit
ddc7f921bd
1 changed files with 13 additions and 7 deletions
|
@ -24,13 +24,19 @@ public partial record Emoji(
|
||||||
|
|
||||||
public partial record Emoji
|
public partial record Emoji
|
||||||
{
|
{
|
||||||
private static string GetTwemojiName(string name) => string.Join("-",
|
private static string GetTwemojiName(string name)
|
||||||
name
|
{
|
||||||
.GetRunes()
|
var runes = name.GetRunes();
|
||||||
// Variant selector rune is skipped in Twemoji names
|
|
||||||
.Where(r => r.Value != 0xfe0f)
|
return string.Join(
|
||||||
.Select(r => r.Value.ToString("x"))
|
"-",
|
||||||
);
|
// Variant selector rune is skipped in Twemoji names, except when the emoji also contains a zero-width joiner.
|
||||||
|
// VS = 0xfe0f. ZWJ = 0x200d.
|
||||||
|
runes.Any(r => r.Value == 0x200d)
|
||||||
|
? runes.Select(r => r.Value.ToString("x"))
|
||||||
|
: runes.Where(r => r.Value != 0xfe0f).Select(r => r.Value.ToString("x"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private static string GetImageUrl(Snowflake id, bool isAnimated) => isAnimated
|
private static string GetImageUrl(Snowflake id, bool isAnimated) => isAnimated
|
||||||
? $"https://cdn.discordapp.com/emojis/{id}.gif"
|
? $"https://cdn.discordapp.com/emojis/{id}.gif"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue