Skip to content
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

src: warn about odd UTF-16 decoding function signature #22623

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ NODE_EXTERN v8::Local<v8::Value> Encode(v8::Isolate* isolate,
size_t len,
enum encoding encoding = LATIN1);

// The input buffer should be in host endianness.
// Warning: This reverses endianness on Big Endian platforms, even though the
// signature using uint16_t implies that it should not.
NODE_EXTERN v8::Local<v8::Value> Encode(v8::Isolate* isolate,
const uint16_t* buf,
size_t len);
Expand Down
5 changes: 4 additions & 1 deletion src/string_bytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ class StringBytes {
enum encoding encoding,
v8::Local<v8::Value>* error);

// The input buffer should be in host endianness.
// Warning: This reverses endianness on BE platforms, even though the
// signature using uint16_t implies that it should not.
// However, the brokenness is already public API and can't therefore
// be changed easily.
static v8::MaybeLocal<v8::Value> Encode(v8::Isolate* isolate,
const uint16_t* buf,
size_t buflen,
Expand Down