Languages
[Edit]
EN

JavaScript - convert string to bytes array (UTF-8)

6 points
Created by:
Eshaal-Wilkinson
774

In this short article, we would like to show, how using JavaScript, convert string to UTF-8 bytes array.

 

Practical examples

Edit

1. Custom solution

Edit

This solution works under older web borsers and Node.js.

 

2. Embedded solution

Edit

This solution appeard in the major web browsers around 2014-2020 and in Node.js v11.

 

3. Optimal solution

Edit

This solution has quite good performance, it works in older web browsers and Node.js.

 

See also

Edit
  1. JavaScript - convert bytes array to string

  2. JavaScript - convert string to bytes array under Node.js

References

Edit
  1. TextEncoder - MDN Docs

Alternative titles

  1. JavaScript - convert string to utf8 bytes array
  2. JavaScript - convert string to UTF-8 bytes array
  3. JavaScript - bytes array from string (UTF-8)
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