{"id":42148023,"url":"https://github.com/Josverl/mp_wcwidth","last_synced_at":"2026-02-05T18:01:12.176Z","repository":{"id":333925751,"uuid":"1139201376","full_name":"Josverl/mp_wcwidth","owner":"Josverl","description":null,"archived":false,"fork":false,"pushed_at":"2026-01-27T14:03:45.000Z","size":20,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-02T04:48:11.290Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Josverl.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-21T16:48:56.000Z","updated_at":"2026-01-27T14:03:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Josverl/mp_wcwidth","commit_stats":null,"previous_names":["josverl/mp_wcwidth"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Josverl/mp_wcwidth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Josverl%2Fmp_wcwidth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Josverl%2Fmp_wcwidth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Josverl%2Fmp_wcwidth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Josverl%2Fmp_wcwidth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Josverl","download_url":"https://codeload.github.com/Josverl/mp_wcwidth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Josverl%2Fmp_wcwidth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29128621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T17:12:17.649Z","status":"ssl_error","status_checked_at":"2026-02-05T17:11:23.670Z","response_time":65,"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":"2026-01-26T18:00:25.748Z","updated_at":"2026-02-05T18:01:12.168Z","avatar_url":"https://github.com/Josverl.png","language":"Python","readme":"# wcwidth - Simplified wcwidth for MicroPython\n\nThis is a simplified version of [wcwidth](https://github.com/jquast/wcwidth) optimized for MicroPython and embedded systems.\n\n## Size Comparison\n\n| Version | Lines of Code | Disk Size | Unicode Versions |\n|---------|---------------|-----------|------------------|\n| **MicroPython  wcwidth** | 746 | 88 KB | 1 version (17.0.0 only) |\n| **Original wcwidth** | 7,888 | 672 KB | 21 versions (4.1.0 - 17.0.0) |\n\n**Size reduction: ~90% (from 672 KB to 88 KB)**\n\n## What's Removed\n\n- Multi-version support (only Unicode 17.0.0 is included)\n- Version selection logic and environment variable handling\n- Standard library `functools.lru_cache` (replaced with simple dict-based cache)\n- VS15 table (not commonly used)\n- Warnings and detailed error messages\n- lru_cache replace by simplistic cache implementation\n  \n## What's Kept\n\n- Full Unicode 17.0.0 character width tables\n- `wcwidth()` - character width measurement\n- `wcswidth()` - string width measurement  \n- Support for:\n  - Wide characters (CJK, emoji, etc.)\n  - Zero-width characters (combining marks, ZWJ, etc.)\n  - VS16 (Variation Selector 16) for emoji modifiers\n  - Control character detection\n\n## Installation\n\nSimplest way to install the module on your MicroPython board is via `mpremote mip`:\n\n```\nmpremote mip install github:josverl/mp_wcwidth\n```\n\n## Usage\n\n```python\nfrom wcwidth import wcwidth, wcswidth\n\n# Get width of a single character\nprint(wcwidth('A'))      # 1 (normal ASCII)\nprint(wcwidth('你'))     # 2 (wide CJK character)\nprint(wcwidth('🪲'))     # 2 (wide emoji)\nprint(wcwidth('\\u0301')) # 0 (combining accent)\nprint(wcwidth('\\n'))     # -1 (control character)\n\n# Get width of a string\nprint(wcswidth('Hello'))         # 5\nprint(wcswidth('你好'))           # 4\nprint(wcswidth('print(\"🪲\")'))   # 11\n```\n\n## Demo\nA simple demo script `demo.py` is included to showcase the functionality:\n\n```bash \n# Install the module and demo script to your MicroPython device\nmpremote mip install github:josverl/mp_wcwidth\nmpremote mip install --target . github:josverl/mp_wcwidth/demo.py\n\n# Run the demo on the device \nmpremote exec \"exec(open('demo.py').read())\"\n```\n\n\n## Caching\n\nThe simplified version includes a minimal cache implementation (`simple_cache.py`) that replaces Python's `functools.lru_cache`:\n\n- **Fixed size**: Uses a simple dict with size limit (no reallocation)\n- **FIFO eviction**: When full, clears entire cache (ultra-simple)\n- **No external dependencies**: Pure Python, MicroPython compatible\n- **Minimal overhead**: ~90 lines of code\n- **Default cache size**: 128 entries for `wcwidth()`\n\nThe cache significantly improves performance for repeated character width lookups.\n\n## Testing\n\nAll basic functionality works identically to the original:\n\n```bash\npython -c \"import wcwidth; print(wcwidth.wcwidth('🪲'))\"  # 2\n\nmpremote exec \"import wcwidth; print(wcwidth.wcwidth('🪲'))\"  # 2\n```\n\n## License\n\nSame as original wcwidth (MIT License)\n\n## Credits\n\nBased on [wcwidth](https://github.com/jquast/wcwidth) by Jeff Quast, which is based on Markus Kuhn's wcwidth.c implementation.\n","funding_links":[],"categories":["Libraries"],"sub_categories":["Utilities"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJosverl%2Fmp_wcwidth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJosverl%2Fmp_wcwidth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJosverl%2Fmp_wcwidth/lists"}