Var buffer1 = om(string1, 'ascii') Ĭonsole.log("buffer1 to ascii = " + buffer1.toString('ascii')) Ĭonsole.log("buffer1 to utf-8 = " + buffer1.toString('utf-8')) Ĭonsole.log("buffer1 to base64 = " + buffer1.toString('base64')) Ĭonsole.log("string2 contains chinese character, so need to use utf-8 encoding to create the Buffer object.") console.log("string1 is a english string totally.") By using explicit character encoding, you can switch between the Buffer instance and the normal JavaScript string.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |