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

windows-1251

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

windows-1251 - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

2

package.json
{
"name": "windows-1251",
"version": "2.0.0",
"version": "3.0.0",
"description": "A robust windows-1251 encoder/decoder written in JavaScript.",

@@ -5,0 +5,0 @@ "homepage": "https://mths.be/windows-1251",

@@ -31,3 +31,3 @@ # windows-1251 [![Build status](https://github.com/mathiasbynens/windows-1251/workflows/run-checks/badge.svg)](https://github.com/mathiasbynens/windows-1251/actions?query=workflow%3Arun-checks) [![windows-1251 on npm](https://img.shields.io/npm/v/windows-1251)](https://www.npmjs.com/package/windows-1251)

This function takes a plain text string (the `input` parameter) and encodes it according to windows-1251. The return value is a ‘byte string’, i.e. a string of which each item represents an octet as per windows-1251.
This function takes a plain text string (the `input` parameter) and encodes it according to windows-1251. The return value is an environment-agnostic `Uint16Array` of which each element represents an octet as per windows-1251.

@@ -38,10 +38,10 @@ ```js

The optional `options` object and its `mode` property can be used to set the [error mode](https://encoding.spec.whatwg.org/#error-mode). For encoding, the error mode can be `'fatal'` (the default) or `'html'`.
The optional `options` object and its `mode` property can be used to set the error mode. The two available error modes are `'fatal'` (the default) or `'replacement'`. (Note: This differs from [the spec](https://encoding.spec.whatwg.org/#error-mode), which recognizes `'fatal`' and `html` modes for encoders. The reason behind this difference is that the spec algorithm is aimed at producing HTML, whereas this library encodes into an environment-agnostic `Uint16Array` of bytes.)
```js
const encodedData = windows1251.encode(text, {
mode: 'html'
mode: 'replacement'
});
// If `text` contains a symbol that cannot be represented in windows-1251,
// instead of throwing an error, it will return an HTML entity for the symbol.
// instead of throwing an error, it becomes 0xFFFD.
```

@@ -51,3 +51,3 @@

This function takes a byte string (the `input` parameter) and decodes it according to windows-1251.
This function decodes `input` according to windows-1251. The `input` parameter can either be a `Uint16Array` of which each element represents an octet as per windows-1251, or a ‘byte string’ (i.e. a string of which each item represents an octet as per windows-1251).

@@ -68,4 +68,2 @@ ```js

For decoding a buffer (e.g. from `fs.readFile`) use `buffer.toString('binary')` to get the byte string which `decode` takes.
## Notes

@@ -72,0 +70,0 @@

Sorry, the diff of this file is not supported yet

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