Skip to content

Commit 261e0c8

Browse files
authored
doc: clarify how StringDecoder.end() handles incomplete input
Signed-off-by: Cleisson Moura <cleissonconstc@gmail.com> Assisted-by: Codex PR-URL: #67760 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 61982a6 commit 261e0c8

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎doc/api/string_decoder.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ added: v0.9.3
9292
* `buffer` {string|Buffer|TypedArray|DataView} The bytes to decode.
9393
* Returns: {string}
9494

95-
Returns any remaining input stored in the internal buffer as a string. Bytes
96-
representing incomplete UTF-8 and UTF-16 characters will be replaced with
97-
substitution characters appropriate for the character encoding.
95+
Returns any remaining input stored in the internal buffer as a string.
96+
An incomplete UTF-8 sequence at the end of the input is decoded as the
97+
replacement character (`U+FFFD`). For UTF-16LE, a trailing byte that does not form
98+
a complete code unit is discarded, and a trailing unpaired high surrogate is
99+
returned as a single code unit.
98100

99101
If the `buffer` argument is provided, one final call to `stringDecoder.write()`
100102
is performed before returning the remaining input.

0 commit comments

Comments
 (0)