We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4a9d8b3 commit b04a0aaCopy full SHA for b04a0aa
1 file changed
Kit/Session-4/StringDecoder/stringDecoder.js
@@ -0,0 +1,24 @@
1
+/***
2
+ * The goal of this file is to know about the string decoder functions;
3
+ * A simple interface to buffer.toString() but provides additional support for utf8.
4
+ *
5
+ * How to run this example:
6
+ * 1. node stringDecoder.js
7
+ * 2. See the message get displayed on prompt.
8
+ */
9
+
10
+var cent = new Buffer([0x40]);
11
+console.log(cent.toString());
12
13
+var StringDecoder = require('string_decoder').StringDecoder;
14
+var decoder = new StringDecoder('utf8');
15
16
17
+ * decoder.write returns a decoded string.
18
19
+cent = new Buffer([0xC2, 0xA2]);
20
+console.log(decoder.write(cent));
21
22
+var euro = new Buffer([0xE2, 0x82, 0xAC]);
23
+console.log(decoder.write(euro));
24
0 commit comments