1
2
3
4
5
6
7
8
9
10
11
12
13
export function hexToUtf8(hex: string) {
if (!hex) {
return;
}
if (hex.startsWith("0x")) {
hex = hex.slice(2);
}
let str = "";
for (let i = 0; i < hex.length; i += 2) {
str += String.fromCharCode(parseInt(hex.slice(i, i + 2), 16));
}
return decodeURIComponent(encodeURIComponent(str));
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023