mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-21 15:09:32 +02:00
fix: updated decode method to handle special characters like emojis and others
This commit is contained in:
@@ -1,20 +1,4 @@
|
|||||||
export function decodeString(input: string): string {
|
export function decodeString(input: string): string {
|
||||||
if (!input) return '';
|
if (!input) return '';
|
||||||
|
return decodeURIComponent(input);
|
||||||
let result = '';
|
|
||||||
let i = 0;
|
|
||||||
|
|
||||||
while (i < input.length) {
|
|
||||||
if (input[i] === '%' && i + 2 < input.length) {
|
|
||||||
const hex = input.substring(i + 1, i + 3);
|
|
||||||
const code = parseInt(hex, 16);
|
|
||||||
result += String.fromCodePoint(code);
|
|
||||||
i += 3;
|
|
||||||
} else {
|
|
||||||
result += input[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user