diff --git a/package.json b/package.json
index ea50afff..71cbd44f 100644
--- a/package.json
+++ b/package.json
@@ -88,6 +88,7 @@
"@types/markdown-it": "^13.0.7",
"@types/memorystream": "^0.3.4",
"@types/sshpk": "^1.17.4",
+ "@unicode/unicode-15.1.0": "^1.5.2",
"@vicons/material": "^0.12.0",
"@vicons/tabler": "^0.12.0",
"@vueuse/core": "^10.11.1",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ff92dbcc..742e5854 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -128,6 +128,9 @@ dependencies:
'@types/turndown':
specifier: ^5.0.4
version: 5.0.5
+ '@unicode/unicode-15.1.0':
+ specifier: ^1.5.2
+ version: 1.6.0
'@vicons/material':
specifier: ^0.12.0
version: 0.12.0
@@ -5669,6 +5672,10 @@ packages:
- '@vue/composition-api'
dev: false
+ /@unicode/unicode-15.1.0@1.6.0:
+ resolution: {integrity: sha512-qGpWJwJ7AtqRrQBjoy4RAuoXlHuQIFcUCXXd4Mh7lcx9B2pVcMZp2eO2G70WydzLsZks/7D27sH30RK7fAnaag==}
+ dev: false
+
/@unocss/astro@0.57.1(rollup@2.79.1)(vite@4.4.9):
resolution: {integrity: sha512-KNaqN/SGM/uz1QitajIkzNEw0jy9Zx9Wp8fl4GhfGYEMAN2+M4cuvBZRmlb6cLctSXmSAJQDG91ivbD1JijGnw==}
peerDependencies:
@@ -15519,6 +15526,7 @@ packages:
/yamljs@0.3.0:
resolution: {integrity: sha512-C/FsVVhht4iPQYXOInoxUM/1ELSf9EsgKH34FofQOp6hwCPrW4vG4w5++TED3xRUo8gD7l0P1J1dLlDYzODsTQ==}
+ hasBin: true
dependencies:
argparse: 1.0.10
glob: 7.2.3
diff --git a/src/tools/index.ts b/src/tools/index.ts
index cf0283de..bf854c54 100644
--- a/src/tools/index.ts
+++ b/src/tools/index.ts
@@ -84,6 +84,7 @@ import { tool as nginxFormatter } from './nginx-formatter';
import { tool as potrace } from './potrace';
import { tool as rmbNumbers } from './rmb-numbers';
import { tool as sensitiveDataMasker } from './sensitive-data-masker';
+import { tool as textToUnicodeNames } from './text-to-unicode-names';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -220,6 +221,7 @@ export const toolsByCategory: ToolCategory[] = [
textToNatoAlphabet,
textToBinary,
textToUnicode,
+ textToUnicodeNames,
yamlToJson,
yamlToToml,
jsonToYaml,
diff --git a/src/tools/text-to-unicode-names/index.ts b/src/tools/text-to-unicode-names/index.ts
new file mode 100644
index 00000000..fb62bc7a
--- /dev/null
+++ b/src/tools/text-to-unicode-names/index.ts
@@ -0,0 +1,12 @@
+import { Language } from '@vicons/tabler';
+import { defineTool } from '../tool';
+
+export const tool = defineTool({
+ name: 'Text to Unicode Names',
+ path: '/text-to-unicode-names',
+ description: 'Convert a text to its hexadecimal character codes and Unicode Names for each character',
+ keywords: ['text', 'unicode', 'name', 'hexa', 'char', 'code'],
+ component: () => import('./text-to-unicode-names.vue'),
+ icon: Language,
+ createdAt: new Date('2024-06-10'),
+});
diff --git a/src/tools/text-to-unicode-names/text-to-unicode-names.service.test.ts b/src/tools/text-to-unicode-names/text-to-unicode-names.service.test.ts
new file mode 100644
index 00000000..fed8ee7d
--- /dev/null
+++ b/src/tools/text-to-unicode-names/text-to-unicode-names.service.test.ts
@@ -0,0 +1,23 @@
+import { describe, expect, it } from 'vitest';
+import { convertTextToUnicodeNames } from './text-to-unicode-names.service';
+
+describe('text-to-unicode-names', () => {
+ describe('convertTextToUnicodeNames', () => {
+ it('a text string is converted to its unicode names representation', () => {
+ expect(convertTextToUnicodeNames('A')).toBe(
+ 'A (U+0041: LATIN CAPITAL LETTER A)');
+ expect(convertTextToUnicodeNames('hello')).toBe(
+ 'h (U+0068: LATIN SMALL LETTER H) e (U+0065: LATIN SMALL LETTER E) l (U+006C: LATIN SMALL LETTER L) l (U+006C: LATIN SMALL LETTER L) o (U+006F: LATIN SMALL LETTER O)');
+ expect(convertTextToUnicodeNames('')).toBe(
+ '');
+ expect(convertTextToUnicodeNames('être 1 $ ¤ …')).toBe(
+ 'ê (U+00EA: LATIN SMALL LETTER E WITH CIRCUMFLEX) t (U+0074: LATIN SMALL LETTER T) r (U+0072: LATIN SMALL LETTER R) e (U+0065: LATIN SMALL LETTER E) (U+0020: SPACE) 1 (U+0031: DIGIT ONE) (U+0020: SPACE) $ (U+0024: DOLLAR SIGN) (U+0020: SPACE) ¤ (U+00A4: CURRENCY SIGN) (U+0020: SPACE) … (U+2026: HORIZONTAL ELLIPSIS)');
+ expect(convertTextToUnicodeNames('⁇ 𥆧 💩')).toBe(
+ '⁇ (U+2047: DOUBLE QUESTION MARK) (U+0020: SPACE) 𥆧 (U+251A7: CJK Ideograph Extension B) (U+0020: SPACE) 💩 (U+1F4A9: PILE OF POO)');
+ });
+ it('the separator between octets can be changed', () => {
+ expect(convertTextToUnicodeNames('hello', { separator: ' ; ' })).toBe(
+ 'h (U+0068: LATIN SMALL LETTER H) ; e (U+0065: LATIN SMALL LETTER E) ; l (U+006C: LATIN SMALL LETTER L) ; l (U+006C: LATIN SMALL LETTER L) ; o (U+006F: LATIN SMALL LETTER O)');
+ });
+ });
+});
diff --git a/src/tools/text-to-unicode-names/text-to-unicode-names.service.ts b/src/tools/text-to-unicode-names/text-to-unicode-names.service.ts
new file mode 100644
index 00000000..4971865d
--- /dev/null
+++ b/src/tools/text-to-unicode-names/text-to-unicode-names.service.ts
@@ -0,0 +1,7 @@
+import unicode from '@unicode/unicode-15.1.0/Names/index.js';
+
+export function convertTextToUnicodeNames(text: string, { separator = ' ' }: { separator?: string } = {}): string {
+ return [...text]
+ .map(char => `${char} (U+${char.codePointAt(0)?.toString(16).toUpperCase().padStart(4, '0')}: ${(unicode.get(char.codePointAt(0)) || 'UNKNOWN CHARACTER')})`)
+ .join(separator);
+}
diff --git a/src/tools/text-to-unicode-names/text-to-unicode-names.vue b/src/tools/text-to-unicode-names/text-to-unicode-names.vue
new file mode 100644
index 00000000..8fb586ff
--- /dev/null
+++ b/src/tools/text-to-unicode-names/text-to-unicode-names.vue
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
diff --git a/src/tools/text-to-unicode-names/unicode.d.ts b/src/tools/text-to-unicode-names/unicode.d.ts
new file mode 100644
index 00000000..0e3362d3
--- /dev/null
+++ b/src/tools/text-to-unicode-names/unicode.d.ts
@@ -0,0 +1,4 @@
+declare module '@unicode/unicode-15.1.0/Names/index.js'{
+ const unicode: HashSet;
+ export default unicode;
+}
\ No newline at end of file