1.0.2 • Published 3 years ago

utf8-js-tools v1.0.2

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
3 years ago

utf8-js-tools

NPM Version

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/utf8-js-tools@1.0.2/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☺