mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
cf0306cd71
This simplifies the stability index to 4 levels: 0 - deprecated 1 - experimental / feature-flagged 2 - stable 3 - locked Domains has been downgraded to deprecated, assert has been downgraded to stable. Timers and Module remain locked. All other APIs are now stable. PR-URL: https://github.com/iojs/io.js/pull/943 Fixes: https://github.com/iojs/io.js/issues/930 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Vladimir Kurchatkin <vladimir.kurchatkin@gmail.com>
728 B
728 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.
var StringDecoder = require('string_decoder').StringDecoder;
var decoder = new StringDecoder('utf8');
var cent = new Buffer([0xC2, 0xA2]);
console.log(decoder.write(cent));
var euro = new Buffer([0xE2, 0x82, 0xAC]);
console.log(decoder.write(euro));
Class: StringDecoder
Accepts a single argument, encoding
which defaults to utf8
.
decoder.write(buffer)
Returns a decoded string.
decoder.end()
Returns any trailing bytes that were left in the buffer.