Transcode JavaScript strings <> UTF-8 byte arrays
npm install utf8-transcoder shell
$ npm install utf8-transcoder
`Test
` shell
$ npm run test
$ npm run test-browser
`
Warning: the tests are very basic at the moment - they only verify that encoding and decoding work for valid 1, 2, 3 and 4 byte code points. Patches welcome to cover things like replacement chars, errors, etc.Bench
On a chromebook, using node@14.6.0:
` shell
$ npm run bench> utf8-transcoder@2.0.1 bench utf8-transcoder
> node bench
encode
TextEncoder: 2.414s
Buffer: 1.334s
this module: 994.79ms
decode
TextDecoder: 8.975s
Buffer: 1.378s
this module: 418.36ms
``