mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
Use blockquotes instead of code blocks for stability markers in the docs. Doing that: - Makes the makers appear correctly when viewed e.g. on github. - Allows remark-lint rules like `no-undefined-references` to work properly (https://github.com/nodejs/node/pull/7729). PR-URL: https://github.com/nodejs/node/pull/7757 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
808 B
808 B
StringDecoder
Stability: 2 - Stable
To use this module, do require('string_decoder'). StringDecoder decodes a
buffer to a string. It is a simple interface to buffer.toString() but provides
additional support for utf8.
const StringDecoder = require('string_decoder').StringDecoder;
const decoder = new StringDecoder('utf8');
const cent = new Buffer([0xC2, 0xA2]);
console.log(decoder.write(cent));
const euro = new Buffer([0xE2, 0x82, 0xAC]);
console.log(decoder.write(euro));
Class: StringDecoder
Accepts a single argument, encoding which defaults to 'utf8'.
decoder.end()
Returns any trailing bytes that were left in the buffer.
decoder.write(buffer)
Returns a decoded string.