mail/front/src/utils/string.ts
2023-04-03 20:11:07 +02:00

9 lines
274 B
TypeScript

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