🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

whatwg-encoding

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
w

whatwg-encoding

Decode strings according to the WHATWG Encoding Standard

3.1.1
latest
100

Supply Chain Security

100

Vulnerability

83

Quality

82

Maintenance

100

License

Version published
Weekly downloads
28M
-13.83%
Maintainers
6
Weekly downloads
 
Created
Issues
3

What is whatwg-encoding?

The whatwg-encoding npm package is a JavaScript implementation of the WHATWG Encoding Standard. It allows for encoding and decoding of text using various character encodings as specified by the standard.

What are whatwg-encoding's main functionalities?

Text Decoding

This feature allows you to decode a Uint8Array of text data into a string using a specified encoding. In the code sample, a Uint8Array representing the UTF-8 encoded string 'Hello' is decoded back into a JavaScript string.

"use strict";
const { decode } = require('whatwg-encoding');
const uint8Array = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f]);
const text = decode(uint8Array, 'utf-8');
console.log(text); // 'Hello'

Text Encoding

This feature allows you to encode a JavaScript string into a Uint8Array using a specified encoding. In the code sample, the string 'Hello' is encoded into a Uint8Array using UTF-8 encoding.

"use strict";
const { encode } = require('whatwg-encoding');
const text = 'Hello';
const uint8Array = encode(text, 'utf-8');
console.log(uint8Array); // Uint8Array showing the bytes of the encoded string

Other packages similar to whatwg-encoding

FAQs

Package last updated on 12 Nov 2023

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