Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/glue/misc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
export function u8s2str(u8s: Uint8Array): string {
return ""; // TODO
return Array.from(u8s).map((u8) => String.fromCharCode(u8)).join("");
}

export function str2u8s(str: string): Uint8Array {
return new Uint8Array(); // TODO
return new Uint8Array(
Array.from(str).map((char) => {
const code = char.codePointAt(0);
if (code == null) throw new Error("Unexpected character");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we throw an error in here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

umm maybe okay

return code;
}),
);
}