mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-20 14:56:17 -04:00
feat(new-tool): added unicode conversion utilities (#858)
* feat: add Text to Unicode tool * Update src/tools/text-to-unicode/index.ts --------- Co-authored-by: Corentin THOMASSET <corentin.thomasset74@gmail.com>
This commit is contained in:
parent
670f735501
commit
c46207f1bb
7 changed files with 103 additions and 0 deletions
9
src/tools/text-to-unicode/text-to-unicode.service.ts
Normal file
9
src/tools/text-to-unicode/text-to-unicode.service.ts
Normal file
|
@ -0,0 +1,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 };
|
Loading…
Add table
Add a link
Reference in a new issue