1.0.2 • Published 6 years ago

text-encoding-utf-8 v1.0.2

Weekly downloads
81,830
License
-
Repository
github
Last release
6 years ago

text-encoding-utf-8

This is a partial polyfill for the Encoding Living Standard API for the Web, allowing encoding and decoding of textual data to and from Typed Array buffers for binary data in JavaScript.

This is fork of text-encoding that only support UTF-8.

Basic examples and tests are included.

Install

There are a few ways you can get the text-encoding-utf-8 library.

Node

text-encoding-utf-8 is on npm. Simply run:

npm install text-encoding-utf-8

Or add it to your package.json dependencies.

HTML Page Usage

  <script src="encoding.js"></script>

API Overview

Basic Usage

  var uint8array = TextEncoder(encoding).encode(string);
  var string = TextDecoder(encoding).decode(uint8array);

Streaming Decode

  var string = "", decoder = TextDecoder(encoding), buffer;
  while (buffer = next_chunk()) {
    string += decoder.decode(buffer, {stream:true});
  }
  string += decoder.decode(); // finish the stream

Encodings

Only utf-8 and UTF-8 are supported.

Non-Standard Behavior

Only utf-8 and UTF-8 are supported.

Motivation

Binary size matters, especially on a mobile phone. Safari on iOS does not support TextDecoder or TextEncoder.

@slickgrid-universal/file-exportthreerendercesiumscontrolled-react-lazylog@infinitebrahmanuniverse/nolb-text-itowns-for-meitowns-test-deployment-3itowns-test-deployment-4itowns-test-deployment-5@everything-registry/sub-chunk-2929itowns-test-deploy-with-provenanceitowns-geocommunsitownsgaiamorgan-testingnear-api-esmnear-api-external-link-forknear-api-js-clonenear-api-js-dannynear-api-js-skynearlibmatrix-react-sdk-almawavematrix-react-sdk-dxmbmatrix-react-sdk-vjenefti-galeridynamics-contracts-xflux-near-apigassefals@parallelnft/web3modalproxied-near-api-jsreact-combilazylogreact-lazylogreact-lazylog-adjustedreact-lazylog-lightreact-lazylog-timestampsreact-lazylog-xreact-miotech-lazylogpeer-vpa-modpersistent-creact-eagerlogzona-xxiabing-near-api-js@gliegard/itowns-immersif@gchoqueux/itowns@fitbit/bison-i18n@ifanshx/cycgodsvoluptatesid@jpmorganchase/perspectivethree-render-cesiumthree-render-cesium2three-cesiumsshelchin-borshsodium-hkdftanya-api-jstest-410-session-key-util-jssimple-asymmetric-js@mtbl/matrix-react-sdk@manishoo/near-api-js@pourfex/itowns@morgs-testing/near-api-js@linear-protocol/near-api-js@solvei/borsh@tripod/openpgp@siendoricardo/near-api-js@pubkeeper/client@pubkeeper/protocol-legacy@pubkeeper/protocol-v1@pubkeeper/protocol-v1-1@slickgrid-universal/text-export@spotlightdata/document-viewer@sssoflyyy/react-logs@safely-project/safely-ts@s2g/borsh@suri-project/fankor@tarnadas/near-api-js@xinyifly/lino-react-lazylog@westake/borshangular-slickgrid-fix@app-config/encryption@alohahealth/matrix-react-sdk@667/near-api-js@autra/giro3d@autra/itowns@bonfida/borsh-js@blockworks-foundation/borsh@bloc-in-bloc/itownscarv_near-api-jscontrolled-lazylogchannels-commonchannels-rest-client@convergencerfq/rfq-sdkcycgodsdouble-ratchet-ts@duoduo-oba/neo4j-driver@duygucelor/itowns@es-git/core
1.0.2

6 years ago

1.0.1

8 years ago

1.0.0

8 years ago