src: warn about odd UTF-16 decoding function signature

Using a `uint16_t` sequence for UTF-16 processing would typically
imply that the sequence already contains the correct 16-bit
code units.

However, our API does not account for that. The previous comments
were somewhat misleading, since endianness is typically applied to
sequences of bytes, which is not something that this API works with.

PR-URL: https://github.com/nodejs/node/pull/22623
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Anna Henningsen committed 2018-09-03 22:32:06 +02:00
1 parent c0e3af1bf2
commit 6455bea52b
2 files changed
+6 -2

No files matched your search

+2 -1
View File
@@ -416,7 +416,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);