mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-20 06:55:06 -04:00

* feat: add Text to Unicode tool * Update src/tools/text-to-unicode/index.ts --------- Co-authored-by: Corentin THOMASSET <corentin.thomasset74@gmail.com>
9 lines
335 B
TypeScript
9 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 };
|