aboutsummaryrefslogtreecommitdiff
path: root/src/tools/text-to-unicode/text-to-unicode.service.ts
blob: e7772cf8961a505d952e9efe0aea2dbb5831e83c (plain) (blame)
1
2
3
4
5
6
7
8
9
function convertTextToUnicode(text: string): string {
  return text.split('').map(value => `&#${value.charCodeAt(0)};`).join('');
}

function convertUnicodeToText(unicodeStr: string): string {
  return unicodeStr.replace(/&#(\d+);/g, (match, dec) => String.fromCharCode(dec));
}

export { convertTextToUnicode, convertUnicodeToText };