INNER CODE UNIT · JavaScript
bytesToString
codedogQBY/ReadAny · packages/app-expo/index.js:10
function bytesToString(bytes) {
if (typeof TextDecoder !== "undefined") {
return new TextDecoder().decode(bytes);
}
let result = "";
const chunkSize = 0x8000;
for (let i = 0; i < bytes.length; i += chunkSize) {
result += String.fromCharCode(...bytes.subarray(i, i + chunkSize));
}
return result;
}
function hexToArrayBuffer(hex) {
const normalized = hex.trim();
const bytes = new Uint8Array(normalized.length / 2);
for (let i = 0; i < normalized.length; i += 2) {
bytes[i / 2] = Number.parseInt(normalized.slice(i, i + 2), 16);