New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

whatwg-encoding

Package Overview
Dependencies
Maintainers
6
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whatwg-encoding

Decode strings according to the WHATWG Encoding Standard

3.1.1
latest
Source
npm
Version published
Weekly downloads
23M
-16.79%
Maintainers
6
Weekly downloads
 
Created

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

Keywords

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