{"id":13586945,"url":"https://github.com/micl2e2/bwrap","last_synced_at":"2025-12-12T14:47:35.585Z","repository":{"id":173937563,"uuid":"651430958","full_name":"micl2e2/bwrap","owner":"micl2e2","description":"A fast, lightweight, embedded system-friendly library for wrapping text.","archived":false,"fork":false,"pushed_at":"2024-02-17T14:43:27.000Z","size":325,"stargazers_count":61,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-17T23:01:49.686Z","etag":null,"topics":["embedded-systems","formatting","newline","no-std","no-std-alloc","rust","text-wrapping","unicode","wordwrap"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/bwrap","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/micl2e2.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":"LICENSE-DEPS/LICENSE-MIT_unicode-width","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}},"created_at":"2023-06-09T08:13:42.000Z","updated_at":"2024-08-01T16:32:57.322Z","dependencies_parsed_at":"2023-07-24T11:09:59.727Z","dependency_job_id":"da25a1cf-ccc2-4f7d-9217-3170e7d3c55b","html_url":"https://github.com/micl2e2/bwrap","commit_stats":null,"previous_names":["imichael2e2/bwrap","micl2e2/bwrap"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micl2e2%2Fbwrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micl2e2%2Fbwrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micl2e2%2Fbwrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/micl2e2%2Fbwrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/micl2e2","download_url":"https://codeload.github.com/micl2e2/bwrap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247707853,"owners_count":20982862,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["embedded-systems","formatting","newline","no-std","no-std-alloc","rust","text-wrapping","unicode","wordwrap"],"created_at":"2024-08-01T15:05:55.557Z","updated_at":"2025-12-12T14:47:30.565Z","avatar_url":"https://github.com/micl2e2.png","language":"Rust","readme":"# bwrap\n\n[![crates][api_crate]][url_crate] [![unsafe][api_unsafe]][url_unsafe]\n[![dep_status][api_depstatus]][url_depstatus] ![api_license][url_license]\n\n[api_crate]: https://img.shields.io/crates/v/bwrap.svg\n[url_crate]: https://crates.io/crates/bwrap\n[api_license]: Crates.io\n[url_license]: https://img.shields.io/crates/l/bwrap\n[api_unsafe]: https://img.shields.io/badge/unsafe-forbidden-success.svg\n[url_unsafe]: https://github.com/rust-secure-code/safety-dance/\n[api_depstatus]: https://deps.rs/repo/github/micl2e2/bwrap/status.svg\n[url_depstatus]: https://deps.rs/repo/github/micl2e2/bwrap\n\n# Table of Contents\n\n- [About](#about)\n- [Benchmark](#benchmark)\n- [Features](#features)\n- [Examples](#examples)\n  - [Multilingual](#multilingual)\n    - [English, Ukrainian, Greek, etc.](#english-ukrainian-greek-etc)\n    - [Chinese, Japanese, Thai, etc.](#chinese-japanese-thai-etc)\n  - [Text Appending](#text-appending)\n    - [Indentation](#indentation)\n    - [Trailing notation](#trailing_notation)\n- [Contributing](#contributing)\n- [License](#license)\n\n\n\n# About\n\nBwrap is a fast, lightweight, embedded system-friendly library for\nwrapping text. While bwrap offers great flexibility in wrapping text,\nneither resource consumption nor performance compromises: \n\n1.  No heap allocation happens by default.\n\n2.  The time/space complexity is *O(n)* by default, or *O(n(p+a))* if\n    there is appending/prepending. (*n*, *p*, *a* is the number of\n    input/prepending/appending bytes respectively) \n\nFor the sake of readability, we **b**etter **wrap** our text. \n\n\n\n# Benchmark\n\nBelow are the performance comparisons among several text-wrapping\nlibraries in different dimensions:\n\n**Time:**\n\n\u003cimg\nsrc=\"https://github.com/micl2e2/bench-wrap-libs/blob/master/examples/result-rtime.png\"\nwidth=\"600px\"/\u003e\n\n**Memory:**\n\n\u003cimg\nsrc=\"https://github.com/micl2e2/bench-wrap-libs/blob/master/examples/result-mempeak.png\"\nwidth=\"600px\"/\u003e\n\nNote:\n\n1.  The benchmark is reproduciable, details about benchmark samples or\n    methods are elaborated in\n    [bench-wrap-libs](https://github.com/micl2e2/bench-wrap-libs). \n\n2.  The data above is obtained on an i5-3337u/8G machine and is for\n    reference only. It is possible to have a slightly different result\n    on a different machine or with different idle system resource. \n\n\n# Features\n\n`use_std`: Use Rust standard library(libstd) for automatic memory management.\n\n\n# Examples\n\nNote that the following examples require `use_std` feature.\n\n## Multilingual\n\nbwrap suuport multiple languages, it categorizes languages into two\ncategories: **space-sensitive** and **space-insensitive**. The former\nis for the languages that depend on ASCII SPACE to delimit words, such\nas English, Ukrainian, Greek and so on. The latter is for the\nlanguages that are space-insensitive, such as Chinese, Japanese, Thai\nand so on. \n\n\n### English, Ukrainian, Greek, etc.\n\n-   English\n\n    Original:\n    \n    ```\n    one two three four five six seven eight nine ten one two three four five six seven eight nine ten one two three four five six seven eight nine ten\n    ```\n    \n    **Wrapped**:\n    \n    ```\n    one two three four five six seven eight nine ten\n    one two three four five six seven eight nine ten\n    one two three four five six seven eight nine ten\n    ```\n    \n    Source code:\n    \n    ```rust\n    let line = \"one two three four five six seven eight nine ten one two three four five six seven eight nine ten one two three four five six seven eight nine ten\";\n    println!(\"ORIGINAL:\\n\\n{}\\n\", line);\n    println!(\"WRAPPED:\\n\\n{}\", bwrap::wrap!(line, 50));\n    ```\n\n-   Ukrainian\n\n    Original:\n    \n    ```\n    один два три чотири п'ять шість сім вісім дев'ять десять один два три чотири п'ять шість сім вісім дев'ять десять один два три чотири п'ять шість сім вісім дев'ять десять\n    ```\n    \n    **Wrapped**:\n    \n    ```\n    один два три чотири п'ять шість сім вісім дев'ять десять\n    один два три чотири п'ять шість сім вісім дев'ять десять\n    один два три чотири п'ять шість сім вісім дев'ять десять\n    ```\n    \n    Source code:\n    \n    ```rust\n    let line = \"один два три чотири п'ять шість сім вісім дев'ять десять один два три чотири п'ять шість сім вісім дев'ять десять один два три чотири п'ять шість сім вісім дев'ять десять\";\n    println!(\"ORIGINAL:\\n\\n{}\\n\", line);\n    println!(\"WRAPPED:\\n\\n{}\", bwrap::wrap!(line, 60));\n    ```\n\n-   Greek\n\n    Original:\n    \n    ```\n    ένα δύο τρία τέσσερα πέντε έξι επτά οκτώ εννέα δέκα ένα δύο τρία τέσσερα πέντε έξι επτά οκτώ εννέα δέκα ένα δύο τρία τέσσερα πέντε έξι επτά οκτώ εννέα δέκα\n    ```\n    \n    **Wrapped**:\n    \n    ```\n    ένα δύο τρία τέσσερα πέντε έξι επτά οκτώ εννέα δέκα\n    ένα δύο τρία τέσσερα πέντε έξι επτά οκτώ εννέα δέκα\n    ένα δύο τρία τέσσερα πέντε έξι επτά οκτώ εννέα δέκα\n    ```\n    \n    Source code:\n    \n    ```rust\n    let line = \"ένα δύο τρία τέσσερα πέντε έξι επτά οκτώ εννέα δέκα ένα δύο τρία τέσσερα πέντε έξι επτά οκτώ εννέα δέκα ένα δύο τρία τέσσερα πέντε έξι επτά οκτώ εννέα δέκα\";\n    println!(\"ORIGINAL:\\n\\n{}\\n\", line);\n    println!(\"WRAPPED:\\n\\n{}\", bwrap::wrap!(line, 51));\n    ```\n\n\n### Chinese, Japanese, Thai, etc.\n\n-   Chinese\n\n    Original:\n    \n    ```\n    一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十\n    ```\n    \n    **Wrapped**:\n    \n    ```\n    一二三四五六七八九十\n    一二三四五六七八九十\n    一二三四五六七八九十\n    ```\n    \n    Source code:\n    \n    ```rust\n    let line = \"一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十\";\n    println!(\"ORIGINAL:\\n\\n{}\\n\", line);\n    println!(\"WRAPPED:\\n\\n{}\", bwrap::wrap_maybrk!(line, 20));\n    ```\n\n-   Japanese\n\n    Original:\n    \n    ```\n    ありがとうございますありがとうございますありがとうございます\n    ```\n    \n    **Wrapped**:\n    \n    ```\n    ありがとうございます\n    ありがとうございます\n    ありがとうございます\n    ```\n    \n    Source code:\n    \n    ```rust\n    let line = \"ありがとうございますありがとうございますありがとうございます\";\n    println!(\"ORIGINAL:\\n\\n{}\\n\", line);\n    println!(\"WRAPPED:\\n\\n{}\", bwrap::wrap_maybrk!(line, 20));\n    ```\n\n-   Thai\n\n    Original:\n    \n    ```\n    หนึ่งสองสามสี่ห้าหกเจ็ดแปดเก้าสิบหนึ่งสองสามสี่ห้าหกเจ็ดแปดเก้าสิบหนึ่งสองสามสี่ห้าหกเจ็ดแปดเก้าสิบ\n    ```\n    \n    **Wrapped**:\n    \n    ```\n    หนึ่งสองสามสี่ห้าหกเจ็ดแปดเก้าสิบ\n    หนึ่งสองสามสี่ห้าหกเจ็ดแปดเก้าสิบ\n    หนึ่งสองสามสี่ห้าหกเจ็ดแปดเก้าสิบ\n    ```\n    \n    Source code:\n    \n    ```rust\n    let line = \"หนึ่งสองสามสี่ห้าหกเจ็ดแปดเก้าสิบหนึ่งสองสามสี่ห้าหกเจ็ดแปดเก้าสิบหนึ่งสองสามสี่ห้าหกเจ็ดแปดเก้าสิบ\";\n    println!(\"ORIGINAL:\\n\\n{}\\n\", line);\n    println!(\"WRAPPED:\\n\\n{}\", bwrap::wrap_maybrk!(line, 25));\n    ```\n\n\n\n## Text Appending\n\nbwrap can append or prepend whatever string to newly added newline\ncharacter. With this feature, one can effectively achieve indentation,\nline trailing notation or similar. \n\n\n\n### Indentation\n\nOriginal:\n\n```\nHere is our schedule:\n- Do A, and do B, and do C, and do D, and do E, and do F\n- Do G, and do H, and do I, and do J, and do K, and do L\n```\n\n**Wrapped**:\n\n```\nHere is our schedule:\n- Do A, and do B, and do C, and do\n  D, and do E, and do F\n- Do G, and do H, and do I, and do\n  J, and do K, and do L\n```\n\nSource code:\n\n```rust\nlet line = \"Here is our schedule:\\n- Do A, and do B, and do C, and do D, and do E, and do F\\n- Do G, and do H, and do I, and do J, and do K, and do L\";\nprintln!(\"ORIGINAL:\\n\\n{}\\n\", line);\nprintln!(\"WRAPPED:\\n\\n{}\", bwrap::wrap_nobrk!(line, 35, \"  \"));\n```\n\n\n### Trailing notation\n\nOriginal:\n\n```\nVGhpcyBpcyBhIHNlY3JldCBtZXNzYWdlLCBwbGVhc2UgZGVsZXRlIGFmdGVyIHJlYWQK\n```\n\n**Wrapped**:\n\n```\nVGhpcyBpcy |\nBhIHNlY3Jl |\ndCBtZXNzYW |\ndlLCBwbGVh |\nc2UgZGVsZX |\nRlIGFmdGVy |\nIHJlYWQK  \n```\n\nSource code:\n\n```rust\nlet line = \"VGhpcyBpcyBhIHNlY3JldCBtZXNzYWdlLCBwbGVhc2UgZGVsZXRlIGFmdGVyIHJlYWQK\";\nprintln!(\"ORIGINAL:\\n\\n{}\\n\", line);\nprintln!(\"WRAPPED:\\n\\n{}\", bwrap::wrap_maybrk!(line, 10, \" |\"));\n```\n\n\n# Contributing\n\nbwrap is still far from perfect, any form of contribution is welcomed!\n\nThis is not an exhaustive list:\n\n- Ask question (label [![](https://img.shields.io/static/v1?label=\u0026message=question\u0026color=purple)](https://github.com/micl2e2/bwrap/issues/new))\n- Bug Report (label [![](https://img.shields.io/static/v1?label=\u0026message=bug\u0026color=red)](https://github.com/micl2e2/bwrap/issues/new))\n- Feature Request (label [![](https://img.shields.io/static/v1?label=\u0026message=enhancement\u0026color=lightblue)](https://github.com/micl2e2/bwrap/issues/new))\n- Documentation Improvement (label [![](https://img.shields.io/static/v1?label=\u0026message=enhancement\u0026color=lightblue)](https://github.com/micl2e2/bwrap/issues/new))\n- Code Contribution\n\n\n\n# License\n\nbwrap can be licensed under either [MIT\nLicense](https://github.com/micl2e2/bwrap/blob/master/LICENSE-MIT) **or**\n[GNU General Public License Version\n3.0](https://github.com/micl2e2/bwrap/blob/master/LICENSE-GPL). The\nchoice is **entirely** up to you. \n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicl2e2%2Fbwrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicl2e2%2Fbwrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicl2e2%2Fbwrap/lists"}