{ "source": "doc/api/string_decoder.md", "modules": [ { "textRaw": "String Decoder", "name": "string_decoder", "stability": 2, "stabilityText": "Stable", "desc": "

To use this module, do require('string_decoder'). StringDecoder decodes a\nbuffer to a string. It is a simple interface to buffer.toString() but provides\nadditional support for utf8.

\n
const StringDecoder = require('string_decoder').StringDecoder;\nconst decoder = new StringDecoder('utf8');\n\nconst cent = new Buffer([0xC2, 0xA2]);\nconsole.log(decoder.write(cent));\n\nconst euro = new Buffer([0xE2, 0x82, 0xAC]);\nconsole.log(decoder.write(euro));\n
\n", "classes": [ { "textRaw": "Class: StringDecoder", "type": "class", "name": "StringDecoder", "meta": { "added": [ "v0.1.99" ] }, "desc": "

Accepts a single argument, encoding which defaults to 'utf8'.

\n", "methods": [ { "textRaw": "decoder.end()", "type": "method", "name": "end", "meta": { "added": [ "v0.9.3" ] }, "desc": "

Returns any trailing bytes that were left in the buffer.

\n", "signatures": [ { "params": [] } ] }, { "textRaw": "decoder.write(buffer)", "type": "method", "name": "write", "meta": { "added": [ "v0.1.99" ] }, "desc": "

Returns a decoded string.

\n", "signatures": [ { "params": [ { "name": "buffer" } ] } ] } ] } ], "type": "module", "displayName": "String Decoder" } ] }