-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[WIP]Fix calling Buffer.toString
with (offset, length, encoding)
#3467
Conversation
export function utf8Slice(this: BufferExt, offset, length) { | ||
return this.toString(offset, length, "utf8"); | ||
export function utf8Slice(this: BufferExt, start, end) { | ||
return this.toString("utf8", start, end); |
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.
start
and end
are used instead of offset
and length
to maintain compatibility with nodejs.
expect(buf.ucs2Slice(2, 6)).toStrictEqual("いう"); | ||
}); | ||
|
||
it("Buffer.base64Slice()", () => { |
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 get a segmentfault in the base64-related tests on my local machine. I don't know what happened here.
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.
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 vaguely remember @cirospaciari running into strange issues with .toBase64URL as well... I think we should switch to using the SIMD base64 library that Node.js also uses. Our current implementation uses a mix of WebKit's internal atob
function and Zig's standard library. I would guess the cause of this is the Zig standard library usage, but it's hard to say without digging deeper
offset = static_cast<uint32_t>(istart); | ||
length = (length > offset) ? (length - offset) : 0; | ||
} else { | ||
int32_t ioffset = arg1.toInt32(lexicalGlobalObject); |
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.
toInt32
can throw, we should technically check for exceptions here (we did not before)
|
||
expect(buf.asciiSlice()).toStrictEqual("0123456789"); | ||
expect(buf.asciiSlice(3)).toStrictEqual("3456789"); | ||
expect(buf.asciiSlice(3, 4)).toStrictEqual("3"); |
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.
These tests are failing
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.
oh its failing because we need to commit regenerated builtins
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.
Thank you. I had mistakenly thought that the generated code was not required for commit.
Manually tested, looks good. Thank you for this! |
@Jarred-Sumner |
Close: #3085
Buffer.toString
with(offset, length, encoding)
utf8Slice
,latin1Slice
, ...