windows-874
Advanced tools
Comparing version 2.0.0 to 3.0.0
{ | ||
"name": "windows-874", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "A robust windows-874 encoder/decoder written in JavaScript.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://mths.be/windows-874", |
@@ -31,3 +31,3 @@ # windows-874 [![Build status](https://github.com/mathiasbynens/windows-874/workflows/run-checks/badge.svg)](https://github.com/mathiasbynens/windows-874/actions?query=workflow%3Arun-checks) [![windows-874 on npm](https://img.shields.io/npm/v/windows-874)](https://www.npmjs.com/package/windows-874) | ||
This function takes a plain text string (the `input` parameter) and encodes it according to windows-874. The return value is a ‘byte string’, i.e. a string of which each item represents an octet as per windows-874. | ||
This function takes a plain text string (the `input` parameter) and encodes it according to windows-874. The return value is an environment-agnostic `Uint16Array` of which each element represents an octet as per windows-874. | ||
@@ -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 = windows874.encode(text, { | ||
mode: 'html' | ||
mode: 'replacement' | ||
}); | ||
// If `text` contains a symbol that cannot be represented in windows-874, | ||
// 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-874. | ||
This function decodes `input` according to windows-874. The `input` parameter can either be a `Uint16Array` of which each element represents an octet as per windows-874, or a ‘byte string’ (i.e. a string of which each item represents an octet as per windows-874). | ||
@@ -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
12120
346
0
78