js-utf8
js-utf8 is a UTF-8 encoder/decoder for Nodejs and Browser
Install
Usage
const raw = '56\u0020你好 🚀' const arr = const str = consoleconsoleconsoleconsole// raw: 56 你好 🚀// arr: [// [ 53 ],// [ 54 ],// [ 32 ],// [ 228, 189, 160 ],// [ 229, 165, 189 ],// [ 32 ],// [ 240, 159, 154, 128 ]// ]// str: 56 你好 🚀// raw === str: true
API
- toArray: convert string to utf8 encoded byte array
- toString: convert utf8 encoded byte array to string