New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

js-utf8

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-utf8

js-utf8 is a UTF-8 encoder/decoder for Nodejs and Browser

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

js-utf8

js-utf8 is a UTF-8 encoder/decoder for Nodejs and Browser

Install

NPM

Usage

import { toArray, toString } from 'js-utf8'

const raw = '56\u0020你好 🚀'

const arr = toArray(raw)
const str = toString(arr)

console.log('raw:', raw)
console.log('arr:', arr)
console.log('str: ', str)
console.log('raw === str: ', raw === str)
// raw: 56 你好 🚀
// arr: [
//   [ 53 ],
//   [ 54 ],
//   [ 32 ],
//   [ 228, 189, 160 ],
//   [ 229, 165, 189 ],
//   [ 32 ],
//   [ 240, 159, 154, 128 ]
// ]
// str:  56 你好 🚀
// raw === str:  true

API

  • toArray: convert string to utf8 encoded byte array
function toArray (str: string): Array<number[]>
  • toString: convert utf8 encoded byte array to string
function toString (arr: Array<number[]>): string

Keywords

utf8

FAQs

Package last updated on 14 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts