summaryrefslogtreecommitdiff
path: root/doc/api/string_decoder.md
diff options
context:
space:
mode:
authorRobert Jefe Lindstaedt <robert.lindstaedt@gmail.com>2016-04-21 00:12:40 +0200
committerJames M Snell <jasnell@gmail.com>2016-04-20 16:34:27 -0700
commit0800c0aa7275bf389b157e1568fa61b59285ad86 (patch)
treea0b739491c4b0170fc333b1b57d61e6d7ae1ca58 /doc/api/string_decoder.md
parentcff2a137f201604cbb3c4e54578b4ebfd20bcaf2 (diff)
downloadandroid-node-v8-0800c0aa7275bf389b157e1568fa61b59285ad86.tar.gz
android-node-v8-0800c0aa7275bf389b157e1568fa61b59285ad86.tar.bz2
android-node-v8-0800c0aa7275bf389b157e1568fa61b59285ad86.zip
doc: git mv to .md
* doc: rename .markdown references in content * doc: rename to .md in tools * doc: rename to .md in CONTRIBUTING.md PR-URL: https://github.com/nodejs/node/pull/4747 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: techjeffharris Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'doc/api/string_decoder.md')
-rw-r--r--doc/api/string_decoder.md30
1 files changed, 30 insertions, 0 deletions
diff --git a/doc/api/string_decoder.md b/doc/api/string_decoder.md
new file mode 100644
index 0000000000..d1de27dc4a
--- /dev/null
+++ b/doc/api/string_decoder.md
@@ -0,0 +1,30 @@
+# 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.
+
+```js
+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.