https://github.com/fabiospampinato/utf16le-encoding
UTF16-le encoding, a.k.a. UCS2 encoding, an encoding you probably should never use.
https://github.com/fabiospampinato/utf16le-encoding
encoding ucs-2 ucs2 utf16 utf16le
Last synced: 11 months ago
JSON representation
UTF16-le encoding, a.k.a. UCS2 encoding, an encoding you probably should never use.
- Host: GitHub
- URL: https://github.com/fabiospampinato/utf16le-encoding
- Owner: fabiospampinato
- License: mit
- Created: 2022-03-24T20:58:56.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-01-15T02:35:21.000Z (over 1 year ago)
- Last Synced: 2025-01-15T04:12:10.385Z (over 1 year ago)
- Topics: encoding, ucs-2, ucs2, utf16, utf16le
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# UTF16le
UTF16-le encoding, a.k.a. UCS2 encoding, an encoding you probably should never use.
## Install
```sh
npm install utf16le-encoding
```
## Usage
```ts
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