-
Notifications
You must be signed in to change notification settings - Fork 286
implement TextEncoder #626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
25788f8 to
0c1c497
Compare
| return error.InvalidUtf8Input; | ||
| } | ||
|
|
||
| // raw copy b/c we know the input is utf-8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you'll need to allocate, and can use v directly:
pub fn _encode(_: *const TextEncoder, v: []const u8) !Env.TypedArray(u8) {
....
return .{.values = v}
}If you did need to allocate, you could use the call_arena, which is shorter-lived, since the data gets copied into v8 anyways.
| try runner.testCases(&.{ | ||
| .{ "var encoder = new TextEncoder();", "undefined" }, | ||
| .{ "encoder.encoding;", "utf-8" }, | ||
| .{ "encoder.encode('€');", "Uint8Array(3) [226, 130, 172]" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth testing the error case.
71f8583 to
e792257
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| @@ -0,0 +1,65 @@ | |||
| // Copyright (C) 2023-2024 Lightpanda (Selecy SAS) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2025?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good question. for now all the headers are to 2024. idk if we should update ti. I will talk that with @francisbouvier
| const std = @import("std"); | ||
|
|
||
| const Env = @import("../env.zig").Env; | ||
| const SessionState = @import("../env.zig").SessionState; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused
e792257 to
9922951
Compare
Depends on #627