Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

text-decoding

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

text-decoding

[fork] TextEncoder and TextDecoder (Polyfill for the Encoding Living Standard's API) For Node.JS.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is text-decoding?

The text-decoding npm package provides an implementation of the Encoding Living Standard API for decoding text. This is particularly useful for environments where the TextDecoder interface is not available, such as in certain Node.js versions or specific browsers. It allows for decoding of text from various encoded formats into a string format that JavaScript can work with.

What are text-decoding's main functionalities?

Decoding text from UTF-8

This feature allows for decoding of text from a UTF-8 encoded Uint8Array to a JavaScript string. It's useful for reading binary data that represents text.

"use strict";\nconst { TextDecoder } = require('text-decoding');\nconst uint8Array = new Uint8Array([72, 101, 108, 108, 111]);\nconst decoder = new TextDecoder('utf-8');\nconst text = decoder.decode(uint8Array);\nconsole.log(text); // Outputs: Hello

Decoding text with options

This feature demonstrates decoding with options such as 'ignoreBOM' for ignoring Byte Order Mark and 'fatal' for throwing an error on invalid input. It's useful for more controlled decoding scenarios.

"use strict";\nconst { TextDecoder } = require('text-decoding');\nconst uint8Array = new Uint8Array([226, 130, 172]);\nconst decoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\nconst text = decoder.decode(uint8Array);\nconsole.log(text); // Outputs: €

Other packages similar to text-decoding

Keywords

FAQs

Package last updated on 02 Jul 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc