windows-1251
Advanced tools
Comparing version 2.0.0 to 3.0.0
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12303
359
0
78