quic and dirty fix
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user