Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

utf16le-encoding

fabiospampinato122MIT2.0.2TypeScript support: included

UTF16-le encoding, a.k.a. UCS2 encoding, an encoding you probably should never use.

utf16, utf16le, ucs2, ucs-2, encoding

readme

UTF16le

UTF16-le encoding, a.k.a. UCS2 encoding, an encoding you probably should never use.

Install

npm install utf16le-encoding

Usage

import UTF16le from 'utf16le-encoding';

// Uint8Array encoding & decoding

{
  const raw = 'Hello 😃';
  const uint8 = new TextEncoder ().encode ( raw );
  console.log ( uint8 ); // => Uint8Array(10) [ 72, 101, 108, 108, 111,  32, 240, 159, 152, 131 ]

  const encoded = UTF16le.encode ( uint8 );
  console.log ( encoded ); // => '效汬鿰莘'

  const decoded = UTF16le.decode ( encoded );
  console.log ( decoded ); // => // => Uint8Array(10) [ 72, 101, 108, 108, 111,  32, 240, 159, 152, 131 ]
}

License

MIT © Fabio Spampinato