doc: add print results for examples in StringDecoder

PR-URL: https://github.com/nodejs/node/pull/49326
Refs: https://github.com/nodejs/node/pull/49143
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Jungku Lee 2023-08-28 00:32:47 +09:00 committed by GitHub
parent 5a0777776d
commit b9153af4cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,10 +21,10 @@ const { StringDecoder } = require('node:string_decoder');
const decoder = new StringDecoder('utf8');
const cent = Buffer.from([0xC2, 0xA2]);
console.log(decoder.write(cent));
console.log(decoder.write(cent)); // Prints: ¢
const euro = Buffer.from([0xE2, 0x82, 0xAC]);
console.log(decoder.write(euro));
console.log(decoder.write(euro)); // Prints: €
```
When a `Buffer` instance is written to the `StringDecoder` instance, an
@ -41,7 +41,7 @@ const decoder = new StringDecoder('utf8');
decoder.write(Buffer.from([0xE2]));
decoder.write(Buffer.from([0x82]));
console.log(decoder.end(Buffer.from([0xAC])));
console.log(decoder.end(Buffer.from([0xAC]))); // Prints: €
```
## Class: `StringDecoder`