encoding-helper/README.md

32 lines
740 B
Markdown
Raw Normal View History

2020-05-15 16:08:01 +02:00
# @sapphirecode/encoding-helper
version: 1.0.x
2020-03-06 08:42:42 +01:00
Converting strings between different encodings
2020-05-15 16:08:01 +02:00
## Installation
npm:
> npm i --save @sapphirecode/encoding-helper
yarn:
> yarn add @sapphirecode/encoding-helper
2020-03-06 08:42:42 +01:00
## Usage
```js
2020-05-15 16:08:01 +02:00
const encoding = require('@sapphirecode/encoding-helper');
2020-03-06 08:42:42 +01:00
const hex = encoding.to_hex('abc'); // convert any encoding to hex, default is utf-8
const b64 = encoding.to_b64(hex, 'hex'); // convert any encoding to base64, default is utf-8
const utf8 = encoding.to_utf8(hex, 'hex'); // convert any encoding to utf-8, no default
2020-05-15 16:08:01 +02:00
const hexn = encoding.num_to_hex(10); // convert a number to hex
const num = encoding.hex_to_num('a'); // convert hex to a number
2020-03-06 08:42:42 +01:00
```
2020-05-15 16:08:01 +02:00
## License
MIT © Timo Hocker <timo@scode.ovh>