Languages
[Edit]
EN

JavaScript - convert string to bytes array under Node.js

9 points
Created by:
Richard-Bevan
413

In this short article, we would like to show, how using JavaScript, convert string to bytes array under Node.js.

Quick solution:

or:

 

Practical examples

Edit

Hint: converting string to bytes you need to select the encoding type that should be used to produce bytes array.

1. to UTF-8 bytes:

Edit

Note: go to this article to see pure JavaScript solution.

Output:

 

2. to UTF-16 LE bytes:

Edit

Output:

 

See also

Edit
  1. ASCII Table

  2. ASCII Table in plain/text

  3. JavaScript - convert string to bytes array - Universal Approach

  4. JavaScript - convert bytes array to string - Universal Approach

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join