diff options
author | Minteck <contact@minteck.org> | 2023-01-10 14:54:04 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2023-01-10 14:54:04 +0100 |
commit | 99c1d9af689e5325f3cf535c4007b3aeb8325229 (patch) | |
tree | e663b3c2ebdbd67c818ac0c5147f0ce1d2463cda /alarm/node_modules/html-encoding-sniffer/README.md | |
parent | 9871b03912fc28ad38b4037ebf26a78aa937baba (diff) | |
download | pluralconnect-99c1d9af689e5325f3cf535c4007b3aeb8325229.tar.gz pluralconnect-99c1d9af689e5325f3cf535c4007b3aeb8325229.tar.bz2 pluralconnect-99c1d9af689e5325f3cf535c4007b3aeb8325229.zip |
Update - This is an automated commit
Diffstat (limited to 'alarm/node_modules/html-encoding-sniffer/README.md')
-rw-r--r-- | alarm/node_modules/html-encoding-sniffer/README.md | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/alarm/node_modules/html-encoding-sniffer/README.md b/alarm/node_modules/html-encoding-sniffer/README.md deleted file mode 100644 index 8913991..0000000 --- a/alarm/node_modules/html-encoding-sniffer/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# Determine the Encoding of a HTML Byte Stream - -This package implements the HTML Standard's [encoding sniffing algorithm](https://html.spec.whatwg.org/multipage/syntax.html#encoding-sniffing-algorithm) in all its glory. The most interesting part of this is how it pre-scans the first 1024 bytes in order to search for certain `<meta charset>`-related patterns. - -```js -const htmlEncodingSniffer = require("html-encoding-sniffer"); -const fs = require("fs"); - -const htmlBuffer = fs.readFileSync("./html-page.html"); -const sniffedEncoding = htmlEncodingSniffer(htmlBuffer); -``` - -The returned value will be a canonical [encoding name](https://encoding.spec.whatwg.org/#names-and-labels) (not a label). You might then combine this with the [whatwg-encoding](https://github.com/jsdom/whatwg-encoding) package to decode the result: - -```js -const whatwgEncoding = require("whatwg-encoding"); -const htmlString = whatwgEncoding.decode(htmlBuffer, sniffedEncoding); -``` - -## Options - -You can pass two potential options to `htmlEncodingSniffer`: - -```js -const sniffedEncoding = htmlEncodingSniffer(htmlBuffer, { - transportLayerEncodingLabel, - defaultEncoding -}); -``` - -These represent two possible inputs into the [encoding sniffing algorithm](https://html.spec.whatwg.org/multipage/syntax.html#encoding-sniffing-algorithm): - -- `transportLayerEncodingLabel` is an encoding label that is obtained from the "transport layer" (probably a HTTP `Content-Type` header), which overrides everything but a BOM. -- `defaultEncoding` is the ultimate fallback encoding used if no valid encoding is supplied by the transport layer, and no encoding is sniffed from the bytes. It defaults to `"windows-1252"`, as recommended by the algorithm's table of suggested defaults for "All other locales" (including the `en` locale). - -## Credits - -This package was originally based on the excellent work of [@nicolashenry](https://github.com/nicolashenry), [in jsdom](https://github.com/tmpvar/jsdom/blob/16fd85618f2705d181232f6552125872a37164bc/lib/jsdom/living/helpers/encoding.js). It has since been pulled out into this separate package. |