text-encoding
Advanced tools
Comparing version 0.5.5 to 0.6.0
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "0.5.5", | ||
"version": "0.6.0", | ||
"description": "Polyfill for the Encoding Living Standard's API.", | ||
@@ -18,0 +18,0 @@ "main": "index.js", |
text-encoding | ||
============== | ||
This is a polyfill for the [Encoding Living Standard](https://encoding.spec.whatwg.org/) | ||
API for the Web, allowing encoding and decoding of textual data to and from Typed Array | ||
buffers for binary data in JavaScript. | ||
This is a polyfill for the [Encoding Living | ||
Standard](https://encoding.spec.whatwg.org/) API for the Web, allowing | ||
encoding and decoding of textual data to and from Typed Array buffers | ||
for binary data in JavaScript. | ||
By default it adheres to the spec and does not support *encoding* to non-UTF encodings, | ||
only *decoding*. It is also implemented to match the specification's algorithms, rather | ||
than for performance. The intended use is within Web pages, so it has no dependency | ||
on server frameworks or particular module schemes. | ||
By default it adheres to the spec and does not support *encoding* to | ||
legacy encodings, only *decoding*. It is also implemented to match the | ||
specification's algorithms, rather than for performance. The intended | ||
use is within Web pages, so it has no dependency on server frameworks | ||
or particular module schemes. | ||
@@ -52,4 +54,4 @@ Basic examples and tests are included. | ||
```js | ||
var uint8array = TextEncoder(encoding).encode(string); | ||
var string = TextDecoder(encoding).decode(uint8array); | ||
var uint8array = new TextEncoder().encode(string); | ||
var string = new TextDecoder(encoding).decode(uint8array); | ||
``` | ||
@@ -60,3 +62,3 @@ | ||
```js | ||
var string = "", decoder = TextDecoder(encoding), buffer; | ||
var string = "", decoder = new TextDecoder(encoding), buffer; | ||
while (buffer = next_chunk()) { | ||
@@ -72,10 +74,17 @@ string += decoder.decode(buffer, {stream:true}); | ||
utf-8 ibm866 iso-8859-2 iso-8859-3 iso-8859-4 iso-8859-5 iso-8859-6 iso-8859-7 iso-8859-8 iso-8859-8-i iso-8859-10 iso-8859-13 iso-8859-14 iso-8859-15 iso-8859-16 koi8-r koi8-u macintosh windows-874 windows-1250 windows-1251 windows-1252 windows-1253 windows-1254 windows-1255 windows-1256 windows-1257 windows-1258 x-mac-cyrillic gb18030 hz-gb-2312 big5 euc-jp iso-2022-jp shift_jis euc-kr replacement utf-16be utf-16le x-user-defined | ||
utf-8 ibm866 iso-8859-2 iso-8859-3 iso-8859-4 iso-8859-5 iso-8859-6 | ||
iso-8859-7 iso-8859-8 iso-8859-8-i iso-8859-10 iso-8859-13 iso-8859-14 | ||
iso-8859-15 iso-8859-16 koi8-r koi8-u macintosh windows-874 | ||
windows-1250 windows-1251 windows-1252 windows-1253 windows-1254 | ||
windows-1255 windows-1256 windows-1257 windows-1258 x-mac-cyrillic | ||
gb18030 hz-gb-2312 big5 euc-jp iso-2022-jp shift_jis euc-kr | ||
replacement utf-16be utf-16le x-user-defined | ||
(Some encodings may be supported under other names, e.g. ascii, iso-8859-1, etc. | ||
See [Encoding](https://encoding.spec.whatwg.org/) for additional labels for each encoding.) | ||
(Some encodings may be supported under other names, e.g. ascii, | ||
iso-8859-1, etc. See [Encoding](https://encoding.spec.whatwg.org/) for | ||
additional labels for each encoding.) | ||
Encodings other than **utf-8**, **utf-16le** and **utf-16be** require an additional | ||
`encoding-indexes.js` file to be included. It is rather large | ||
(596kB uncompressed, 188kB gzipped); portions may be deleted if | ||
Encodings other than **utf-8**, **utf-16le** and **utf-16be** require | ||
an additional `encoding-indexes.js` file to be included. It is rather | ||
large (596kB uncompressed, 188kB gzipped); portions may be deleted if | ||
support for some encodings is not required. | ||
@@ -85,6 +94,6 @@ | ||
As required by the specification, only encoding to **utf-8**, | ||
**utf-16le** and **utf-16be** is supported. If you want to try it out, you can | ||
force a non-standard behavior by passing the `NONSTANDARD_allowLegacyEncoding` | ||
option to TextEncoder. For example: | ||
As required by the specification, only encoding to **utf-8**, is | ||
supported. If you want to try it out, you can force a non-standard | ||
behavior by passing the `NONSTANDARD_allowLegacyEncoding` option to | ||
TextEncoder and a label. For example: | ||
@@ -96,4 +105,5 @@ ```js | ||
But note that the above won't work if you're using the polyfill in a browser that | ||
natively supports the TextEncoder API natively, since the polyfill won't be used! | ||
But note that the above won't work if you're using the polyfill in a | ||
browser that natively supports the TextEncoder API natively, since the | ||
polyfill won't be used! | ||
@@ -108,5 +118,6 @@ You can force the polyfill to be used by using this before the polyfill: | ||
To support the legacy encodings (which may be stateful), the TextEncoder `encode()` | ||
method accepts an optional dictionary and `stream` option, | ||
e.g. `encoder.encode(string, {stream: true});` This is not needed for the | ||
stateless UTF encodings since the input is always in complete code points. | ||
To support the legacy encodings (which may be stateful), the | ||
TextEncoder `encode()` method accepts an optional dictionary and | ||
`stream` option, e.g. `encoder.encode(string, {stream: true});` This | ||
is not needed for standard encoding since the input is always in | ||
complete code points. |
Sorry, the diff of this file is too big to display
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
4981
118
637025