quic and dirty fix

This commit is contained in:
2025-05-05 11:26:59 +02:00
parent bfa0ba8edf
commit 9315abc488
4 changed files with 55 additions and 23 deletions

View File

@@ -9,7 +9,15 @@ export function uint_bytes_to_num(value: Uint8Array): number {
export function utf8_encode(value: string): Uint8Array {
const encoder = new TextEncoder();
return encoder.encode(value);
let res: Uint8Array = new Uint8Array(0);
for (const ch of value) {
const cur = encoder.encode(ch)[0];
const prev = res;
res = new Uint8Array(prev.length + 1);
res.set(prev, 0);
res.set([cur], prev.length);
}
return res;
}
export function utf8_decode(value: Uint8Array): string {