{"id":30580364,"url":"https://github.com/borewit/text-codec","last_synced_at":"2026-01-20T17:09:21.993Z","repository":{"id":309773949,"uuid":"1037515604","full_name":"Borewit/text-codec","owner":"Borewit","description":"Lightweight, dependency-free TextEncoder/TextDecoder polyfill supporting UTF-8, UTF-16LE, ASCII, Latin-1, and Windows-1252 for engines like Hermes.","archived":false,"fork":false,"pushed_at":"2025-12-29T21:38:41.000Z","size":92,"stargazers_count":1,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-02T04:09:00.400Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Borewit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"Borewit","buy_me_a_coffee":"borewit"}},"created_at":"2025-08-13T17:32:18.000Z","updated_at":"2025-12-29T21:38:45.000Z","dependencies_parsed_at":"2025-08-29T05:23:32.780Z","dependency_job_id":"cf23777f-6ab8-4480-bf68-c47e7ebf4f15","html_url":"https://github.com/Borewit/text-codec","commit_stats":null,"previous_names":["borewit/text-codec"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Borewit/text-codec","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Borewit%2Ftext-codec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Borewit%2Ftext-codec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Borewit%2Ftext-codec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Borewit%2Ftext-codec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Borewit","download_url":"https://codeload.github.com/Borewit/text-codec/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Borewit%2Ftext-codec/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28607624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T16:10:39.856Z","status":"ssl_error","status_checked_at":"2026-01-20T16:10:39.493Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-29T05:23:17.107Z","updated_at":"2026-01-20T17:09:21.978Z","avatar_url":"https://github.com/Borewit.png","language":"TypeScript","funding_links":["https://github.com/sponsors/Borewit","https://buymeacoffee.com/borewit"],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/Borewit/text-codec/actions/workflows/ci.yml/badge.svg)](https://github.com/Borewit/text-codec/actions/workflows/ci.yml)\n[![npm version](https://img.shields.io/npm/v/%40borewit%2Ftext-codec.svg)](https://www.npmjs.com/package/@borewit/text-codec)\n[![npm downloads](http://img.shields.io/npm/dm/@borewit/text-codec.svg)](https://npmcharts.com/compare/@borewit/text-codec?interval=30)\n![bundlejs](https://deno.bundlejs.com/?q=@borewit/text-codec\u0026badge)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?logo=open-source-initiative\u0026logoColor=white)](LICENSE.txt)\n\n# `@borewit/text-codec`\n\nA **lightweight alternative implementation** of `TextEncoder` / `TextDecoder` supporting common encodings missing in some JavaScript engines and Node.js builds.  \nWorks in environments like **Hermes** (React Native) or **Small-ICU Node.js** where only UTF-8 and UTF-16LE are available.\n\n| Encoding                  | Hermes — **Encode** | Hermes — **Decode** | Small-ICU Node.js — **Encode** | Small-ICU Node.js — **Decode** |\n|---------------------------|---------------------|---------------------|--------------------------------|--------------------------------|\n| **utf-8** / `utf8`        | ➕                   | Native              | Native                         | Native                         |\n| **utf-16le**              | ➕                   | ➕                   | Native                         | Native                         |\n| **ascii**                 | ➕                   | ➕                   | ➕                              | ➕                              |\n| **latin1** / `iso-8859-1` | ➕                   | ➕                   | ➕                              | Native (sometimes)             |\n| **windows-1252**          | ➕                   | ➕                   | ➕                              | ➕                              |\n\n**Legend:**\n- **Native** — Supported natively by the JavaScript engine.\n- **➕** — Support added by this module.\n- **Native (sometimes)** — Available in some builds (e.g., certain Small-ICU Node.js builds).\n---\n\nWhen your project needs to handle encodings like `latin1` / `iso-8859-1` or `windows-1252` in these environments,\nnative `TextDecoder` / `TextEncoder` may throw an error or return incorrect results.\n\n## ✨ Features\n\n- Decoding and encoding\n- Lightweight\n- Typed\n\n### Supported encodings:\n- `utf-8` / `utf8`\n- `utf-16le`\n- `ascii`\n- `latin1` / `iso-8859-1`\n- `windows-1252`\n\n---\n\n## 📦 Installation\n\n```sh\nnpm install @borewit/text-codec\n```\n\n\n# 📚 API Documentation\n\n## `textDecode(bytes, encoding): string`\n\nDecodes binary data into a JavaScript string using the specified encoding.\n\n**Parameters**\n- `bytes` (`Uint8Array`) — The binary data to decode.\n- `encoding` (`SupportedEncoding`, optional) — Encoding type. Defaults to `\"utf-8\"`.  \n\n**Returns**\n- `string` — The decoded text.\n\n**Example**\n```js\nimport { textDecode } from \"@borewit/text-encode\";\n\nconst bytes = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f]);\nconst text = textDecode(bytes, \"ascii\");\nconsole.log(text); // \"Hello\"\n```\nEncodes a JavaScript string into binary form using the specified encoding.\n\n## `textEncode(input, encoding): Uint8Array`\n\n**Parameters**\n\n- `input` (`string`) — The string to encode.\n- `encoding` (`SupportedEncoding`, optional) — Encoding type. Defaults to `\"utf-8\"`.\n\n**Returns**\n\n`Uint8Array` — The encoded binary data.\n\nExample:\n```js\nimport { textEncode } from \"@borewit/text-encode\";\n\nconst bytes = textEncode(\"Hello\", \"utf-16le\");\nconsole.log(bytes); // Uint8Array([...])\n```\n\n## 📜 Licence\n\nThis project is licensed under the [MIT License](LICENSE.txt). Feel free to use, modify, and distribute as needed.\n ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborewit%2Ftext-codec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborewit%2Ftext-codec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborewit%2Ftext-codec/lists"}