utf8-js-tools
v1.0.2
Published
Encode/Decode text in utf8 encoding
Downloads
1
Readme
utf8-js-tools
Encode/Decode text in utf8 encoding
Demo
Online Unicode To UTF8 Converter
With npm
Install
$ npm install --save utf8-js-tools
Import
import { UTF8 } from "utf8-js-tools";
or
const { UTF8 } = require("utf8-js-tools");
In web browsers
<script src="utf8.min.js"></script>
or
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/utf8.min.js"></script>
Usage
Encode
UTF8.encode("u") // \x75
UTF8.encode("\xAF") // \xC2\xAF
UTF8.encode("\u263A") // \xE2\x98\xBA
UTF8.encode("utf\xAF8\u263A") // \x75\x74\x66\xC2\xAF\x38\xE2\x98\xBA
UTF8.encode("utf¯8☺") // \x75\x74\x66\xC2\xAF\x38\xE2\x98\xBA
Decode
UTF8.decode("\x75") // u
UTF8.decode("\xC2\xAF") // \xAF
UTF8.decode("\xE2\x98\xBA") // \u263A
UTF8.decode("\x75\x74\x66\xC2\xAF\x38\xE2\x98\xBA") // utf\xAF8\u263A
UTF8.decode("\x75\x74\x66\xC2\xAF\x38\xE2\x98\xBA") // utf¯8☺