mail/front/src/utils/string.ts
2023-04-07 16:10:23 +02:00

9 lines
284 B
TypeScript

// todo optimize
export function decodeEmojis(text: string | undefined): string {
if (!text) return "";
const regex = /\\u{([^}]+)}/g;
const decodedText = text.replace(regex, (_: string, hex: string) => String.fromCodePoint(parseInt(hex, 16)));
return decodedText;
}