From ef034f2b8b94a9ba60ce8a9a18b7febc778f3062 Mon Sep 17 00:00:00 2001 From: Chesterkxng Date: Sun, 30 Nov 2025 17:56:43 +0100 Subject: [PATCH] chore: void input edge case added to service --- src/pages/tools/string/unicode/service.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/pages/tools/string/unicode/service.ts b/src/pages/tools/string/unicode/service.ts index 9943f64..818f832 100644 --- a/src/pages/tools/string/unicode/service.ts +++ b/src/pages/tools/string/unicode/service.ts @@ -1,20 +1,13 @@ import { InitialValuesType } from './types'; -export function main(input: string, options: InitialValuesType): string { - return input; -} - -export function unicode( - input: string, - encode: boolean, - uppercase: boolean -): string { - if (encode) { +export function unicode(input: string, options: InitialValuesType): string { + if (!input) return ''; + if (options.mode === 'encode') { let result = ''; for (let i = 0; i < input.length; i++) { let hex = input.charCodeAt(i).toString(16); hex = ('0000' + hex).slice(-4); - if (uppercase) { + if (options.uppercase) { hex = hex.toUpperCase(); } result += '\\u' + hex;