{"id":28042527,"url":"https://github.com/browserbox/base437","last_synced_at":"2026-01-22T05:33:32.924Z","repository":{"id":282615021,"uuid":"949073785","full_name":"BrowserBox/Base437","owner":"BrowserBox","description":" Hacking data URLs and Unicode to display binary content inside HTML using IBM Code Page 437 characters from 1980s DOS! ","archived":false,"fork":false,"pushed_at":"2025-03-21T14:44:29.000Z","size":4090,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-29T23:58:33.104Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://browserbox.github.io/Base437/","language":"HTML","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/BrowserBox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2025-03-15T16:05:23.000Z","updated_at":"2025-04-29T06:41:53.000Z","dependencies_parsed_at":"2025-04-16T12:22:13.829Z","dependency_job_id":"1678e57f-709a-40e6-b8d9-fc82963c2ecc","html_url":"https://github.com/BrowserBox/Base437","commit_stats":null,"previous_names":["browserbox/base437","browserbox/base256"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BrowserBox/Base437","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrowserBox%2FBase437","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrowserBox%2FBase437/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrowserBox%2FBase437/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrowserBox%2FBase437/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BrowserBox","download_url":"https://codeload.github.com/BrowserBox/Base437/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BrowserBox%2FBase437/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28656289,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-05-11T14:48:41.381Z","updated_at":"2026-01-22T05:33:32.903Z","avatar_url":"https://github.com/BrowserBox.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Base437 Data Encoding - See Binary the Way It Wants to Be Seen\n\n***As IBM Code Page 437 Characters***\n\n\u003e A retro aesthetic meets modern utility! Base437 brings the nostalgic charm of the original Code Page 437 (OG IBM PC) character set to life, transforming binary data into a mesmerizing display of line-drawing symbols, Greek letters, and accented glyphs—a visual ode to the early computing era. But it’s not just eye candy! For the pragmatic engineer, Base437 strips away Base64’s obfuscation, letting you inspect binary data *close to the metal*. This raw clarity accelerates debugging and deepens your grasp of the data at hand. With a tightly curated 437-character set, Base437 ensures cross-context compatibility, and the intuitive `tr` API—complete with `validate()`—empowers you to sculpt encodings for any domain.\n\n\u003cimg width=\"695\" alt=\"437\" src=\"https://github.com/user-attachments/assets/596fc410-01a9-4557-8745-310a4c1eab27\" /\u003e\n\n[Read more about Code Page 437, a.k.a, \"High ~Elvish~ ASCII\"](https://en.wikipedia.org/wiki/Code_page_437)\n\n## Features\n\n- **Vintage Visuals**: Encodes binary with the iconic Code Page 437 character set for a retro aesthetic.\n- **Efficiency**: 1:1 byte-to-character mapping, outpacing Base64 in compactness.\n- **Cross-Platform**: Seamless operation in Node.js and browsers.\n- **Extensible**: Customize mappings for specific contexts (e.g., HTML, URLs) with the `tr` API.\n- **Validated**: Ensures mapping integrity with `validate()`.\n- **No Dependencies**: Pure JavaScript, lightweight, and self-contained.\n\n## Installation\n\nTo get started, install Base437 via npm:\n\n```bash\nnpm install base437\n```\n\n## Usage\n\n### Basic Encoding/Decoding\n\n```javascript\nimport { encode, decode } from 'base437';\n\n// Encode a string to Base437\nconst text = \"Hello, World!\";\nconst encoded = encode(text);\nconsole.log(encoded); // Displays with CP437 flair (e.g., line art and symbols)\n\n// Decode back to a string\nconst decoded = decode(encoded, 'string');\nconsole.log(decoded); // \"Hello, World!\"\n```\n\n### Using with Data URLs\n\nBase437 includes a built-in method to convert its encoded data URLs to Base64 for browser rendering.\n\n```javascript\nimport { encode, toBase64Url } from 'base437';\n\n// Encode a PNG image to Base437\nconst pngData = new Uint8Array([137, 80, 78, 71, ...]); // PNG binary data\nconst base437Data = encode(pngData);\nconst base437Url = `data:image/png;base437,${base437Data}`;\n\n// Convert to Base64 for browser use\nconst base64Url = toBase64Url(base437Url);\ndocument.querySelector('img').src = base64Url; // Render the image\n```\n\n### CLI Usage\n\nRun Base437 directly from the command line in Node.js.\n\n```bash\n# Encode a file to Base437\nnode base437.js input.bin \u003e output.base437\n\n# Decode a Base437 file back to binary\nnode base437.js output.base437 --decode \u003e input.bin\n```\n\n## Extensibility: Sculpt Your Own Encodings\n\nBase437 is your canvas for creativity! Like base64url adapts Base64 for URLs, Base437 lets you craft domain-specific encodings by remapping characters with the `tr` API. The core mapping preserves the original Code Page 437 set, but you can tweak it to avoid conflicts or enhance safety.\n\n### How It Works\n\nThe `createEncoder` function builds an encoder/decoder pair from a mapping. Use `CoreMapping.tr(byte, newUnicode)` to create an immutable copy with remapped characters, and validate it with `validate()` to ensure no duplicates.\n\n### Mapping Validation\n\nThe `validate()` method checks for duplicate Unicode code points, throwing an error if conflicts arise.\n\n#### Example: base437htmlAttribute\n\nCreate a Base437 encoding safe for HTML attributes by remapping problematic characters:\n\n```javascript\nimport { createEncoder, CoreMapping } from 'base437';\n\n// Customize mapping for HTML safety\nconst htmlSafeMapping = CoreMapping\n  .tr('\"', 'U+201C') // Remap quotation mark\n  .tr('\u003c', 'U+2062') // Remap less-than\n  .tr('\u003e', 'U+2063') // Remap greater-than\n  .tr('\u0026', 'U+2064') // Remap ampersand\n  .validate(); // Ensure no conflicts\n\nconst htmlEncoder = createEncoder(htmlSafeMapping);\n\n// Encode safely for HTML attributes\nconst encoded = htmlEncoder.encode('Hello \"World\" \u003cTest\u003e \u0026 More');\nconsole.log(encoded); // Safe string for HTML use\nconst decoded = htmlEncoder.decode(encoded, 'string');\nconsole.log(decoded); // \"Hello \"World\" \u003cTest\u003e \u0026 More\"\n```\n\n#### Example: Validating a Mapping\n\nPrevent mapping conflicts:\n\n```javascript\nconst invalidMapping = CoreMapping.tr('0', 'U+0020').validate(); // Throws: Duplicate Unicode code point found: U+0020\n```\n\n#### Crafting Other Domains\n\n- `base437url`: Remap `/`, `?`, `#`, `=` for URL safety using invisible Unicode characters.\n- `base437json`: Remap `\\`, `\"` for JSON string safety.\n\nUse `CoreMapping.tr()` to adjust, validate, and pass to `createEncoder`.\n\n## Developer Ergonomics\n\nBase437 is designed with developers in mind:\n\n- **Clear API**: Functions like `encode`, `decode`, and `toBase64Url` are intuitive and mirror Base64 conventions.\n- **Validation**: The `validate()` method ensures your custom mappings are conflict-free.\n- **Flexible Output**: Decode to `Uint8Array`, `ArrayBuffer`, `Buffer`, `string`, or `array` with a single parameter.\n- **Cross-Platform**: Works seamlessly in Node.js and browsers, with a Buffer polyfill for browser compatibility.\n- **No Dependencies**: Pure JavaScript, keeping your project lightweight.\n\n\u003e[!NOTE]  \nBase437 is lightweight and doesn’t rely on any external dependencies, making it a great choice for minimalistic projects and performance-sensitive applications.\n\n## Contributing\n\nWe invite you to shape Base437’s future! Share your custom encodings or enhancements via pull requests. Add reusable mappings to the `mappings/` directory!\n\n\u003e **Note**  \n\u003e Have a cool encoding like `base437url` or `base437json`? Open a PR—we’d love to feature it!\n\n## License\n\nMIT License - See the [LICENSE](LICENSE) file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserbox%2Fbase437","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrowserbox%2Fbase437","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserbox%2Fbase437/lists"}