GeezerVison is showing github.com — src: warn about odd UTF-16 decoding function signature · nodejs/node@f064d44
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node.h +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -424,7 +424,8 @@ NODE_EXTERN v8::Local<v8::Value> Encode(v8::Isolate* isolate, |
424 | 424 | size_t len, |
425 | 425 | enum encoding encoding = LATIN1); |
426 | 426 |
|
427 | | -// The input buffer should be in host endianness. |
| 427 | +// Warning: This reverses endianness on Big Endian platforms, even though the |
| 428 | +// signature using uint16_t implies that it should not. |
428 | 429 | NODE_EXTERN v8::Local<v8::Value> Encode(v8::Isolate* isolate, |
429 | 430 | const uint16_t* buf, |
430 | 431 | size_t len); |
|
Collapse file
Copy file name to clipboardExpand all lines: src/string_bytes.h +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -97,7 +97,10 @@ class StringBytes { |
97 | 97 | enum encoding encoding, |
98 | 98 | v8::Local<v8::Value>* error); |
99 | 99 |
|
100 | | - // The input buffer should be in host endianness. |
| 100 | + // Warning: This reverses endianness on BE platforms, even though the |
| 101 | + // signature using uint16_t implies that it should not. |
| 102 | + // However, the brokenness is already public API and can't therefore |
| 103 | + // be changed easily. |
101 | 104 | static v8::MaybeLocal<v8::Value> Encode(v8::Isolate* isolate, |
102 | 105 | const uint16_t* buf, |
103 | 106 | size_t buflen, |
|