export function transformEmojis(str :string): string { if (!str) return str; // Use a regular expression to match emojis in the string const regex = /[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F900}-\u{1F9FF}\u{1F1E0}-\u{1F1FF}]/gu; // Replace each matched emoji with its Unicode code point const transformedStr = str.replace(regex, (match) => { return "\\u{" + match.codePointAt(0)?.toString(16).toUpperCase() + "}"; }); return transformedStr; } export function decodeEmojis(text: string): string { const regex = /\\u{([^}]+)}/g; const decodedText = text.replace(regex, (_, hex) => String.fromCodePoint(parseInt(hex, 16))); return decodedText; }