mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
Merge branch 'feat/text-to-unicode-names' into chore/all-my-stuffs
# Conflicts: # components.d.ts # package.json # pnpm-lock.yaml # src/components/TextareaCopyable.vue # src/tools/index.ts # vite.config.ts
This commit is contained in:
commit
fd44be4209
8 files changed
+80
No files matched your search
@@ -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",
|
||||
|
||||
Generated
+8
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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'),
|
||||
});
|
||||
@@ -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)');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import { convertTextToUnicodeNames } from './text-to-unicode-names.service';
|
||||
|
||||
const inputText = ref('');
|
||||
const unicodeNamesFromText = computed(() => convertTextToUnicodeNames(inputText.value, { separator: '\n' }));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<c-card title="Text to Unicode Names">
|
||||
<c-input-text
|
||||
v-model:value="inputText"
|
||||
multiline placeholder="e.g. 'Hello world'"
|
||||
label="Enter text to convert to Unicode Names"
|
||||
autosize autofocus raw-text
|
||||
/>
|
||||
<textarea-copyable
|
||||
v-model:value="unicodeNamesFromText"
|
||||
word-wrap
|
||||
label="Unicode Names from your text" multiline raw-text readonly mt-2
|
||||
placeholder="The Unicode Names representation of your text will be here"
|
||||
/>
|
||||
</c-card>
|
||||
</template>
|
||||
@@ -0,0 +1,4 @@
|
||||
declare module '@unicode/unicode-15.1.0/Names/index.js'{
|
||||
const unicode: HashSet<number, string>;
|
||||
export default unicode;
|
||||
}
|
||||
Reference in new issue
Block a user