mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-20 06:55:06 -04:00
10 lines
335 B
TypeScript
10 lines
335 B
TypeScript
![]() |
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 };
|