text-encoding-utf-8 is a partial polyfill for the Web's Encoding Living Standard API, specifically designed to provide UTF-8 encoding and decoding capabilities for environments lacking native `TextEncoder` and `TextDecoder` implementations, such as older versions of Safari on iOS. The current stable version is 1.0.2, last updated over seven years ago. Its key differentiator is its strict focus on UTF-8 only, resulting in a smaller footprint compared to full polyfills like `text-encoding`. While it served a critical role historically, modern browsers and Node.js environments universally support `TextEncoder` and `TextDecoder` natively, rendering this polyfill largely obsolete for new development.
npm install text-encoding-utf-8Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic UTF-8 encoding and decoding using TextEncoder and TextDecoder, including a conceptual example of streaming decode.
Ensure that only 'utf-8' or 'UTF-8' are passed as encoding arguments to TextEncoder and TextDecoder constructors. If other encodings are needed, use a comprehensive polyfill or check for native API support.
For new projects, avoid this polyfill entirely. For existing projects, consider removing it and relying on native browser/Node.js APIs. Use feature detection (`typeof TextEncoder !== 'undefined'`) if targeting very old environments that lack native support.
Implement robust feature detection to conditionally load or apply the polyfill only when `TextEncoder` or `TextDecoder` are genuinely missing. For example: `if (typeof TextEncoder === 'undefined') { require('text-encoding-utf-8'); }`.Modify your code to only use 'utf-8' or 'UTF-8' as the encoding string. If other encodings are required, this polyfill is not suitable, and you should use a more comprehensive library or native APIs.
Ensure the polyfill script (`encoding.js`) is loaded in HTML, or for Node.js/bundlers, verify the import statement is correct (`import 'text-encoding-utf-8';` for global patching, or `import { TextEncoder } from 'text-encoding-utf-8';` for named imports).No dependency data recorded yet.