{"id":28377377,"url":"https://github.com/guillaumeast/libstrui","last_synced_at":"2025-10-08T21:58:35.945Z","repository":{"id":293572072,"uuid":"984463695","full_name":"guillaumeast/libstrui","owner":"guillaumeast","description":"Header-only C++ lib → Clean, measure \u0026 reshape terminal text (Unicode/ANSI-aware)","archived":false,"fork":false,"pushed_at":"2025-05-16T08:29:59.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-26T18:43:22.493Z","etag":null,"topics":["ansi-escape-codes","cpp17","header-only","library","string-utils","terminal","text-processing","unicode","utf-8"],"latest_commit_sha":null,"homepage":"","language":"C++","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/guillaumeast.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}},"created_at":"2025-05-16T01:23:57.000Z","updated_at":"2025-05-16T06:48:42.000Z","dependencies_parsed_at":"2025-06-26T18:34:14.147Z","dependency_job_id":"b125430e-34ab-4fc7-9ec9-2776d192f759","html_url":"https://github.com/guillaumeast/libstrui","commit_stats":null,"previous_names":["guillaumeast/libstrui"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/guillaumeast/libstrui","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guillaumeast%2Flibstrui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guillaumeast%2Flibstrui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guillaumeast%2Flibstrui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guillaumeast%2Flibstrui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guillaumeast","download_url":"https://codeload.github.com/guillaumeast/libstrui/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guillaumeast%2Flibstrui/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000687,"owners_count":26082837,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"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":["ansi-escape-codes","cpp17","header-only","library","string-utils","terminal","text-processing","unicode","utf-8"],"created_at":"2025-05-30T01:04:50.775Z","updated_at":"2025-10-08T21:58:35.902Z","avatar_url":"https://github.com/guillaumeast.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🎨 **`libstrui` v1.0.0**\n\nMinimal Unicode‑aware \u0026 ANSI‑aware string library (header‑only, class‑less)\n\n[![C++](https://img.shields.io/badge/language-C%2B%2B17-blue)](https://en.cppreference.com/)\n[![Type: header‑only](https://img.shields.io/badge/type-header--only-lightgrey)](https://en.wikipedia.org/wiki/Header-only)\n[![Platform: Unix](https://img.shields.io/badge/platform-Unix-darkgreen)](https://en.wikipedia.org/wiki/Unix)\n[![Status: v1.0.0](https://img.shields.io/badge/status-v1.0.0-brightgreen)](https://github.com/guillaumeast/libstrui/releases/tag/v1.0.0)\n\n\u003e **`libstrui`** is a *tiny* **C++17 header‑only library** for measuring terminal strings.  \n\u003e Think of it as `cut`, `sed`, or `wc`, but *escape‑safe*, **UTF‑8‑capable** (incl. wide \u0026 combined emojis).  \n\u003e Ready to drop in **one header**.\n\n---\n\n## ✨ Features\n\n- **UTF‑8 aware** (powered by [`libunistring`](https://www.gnu.org/software/libunistring/))\n- **ANSI / escape‑safe** cleaning \u0026 width detection\n- **Visual width** handling (CJK, wide \u0026 combined emojis)\n- **Line height** calculation\n- **Substring occurrence counting**\n- **Split** \u0026 **repeat** helpers\n- **Zero‑dependency** at runtime, header‑only at build time\n- Plays nicely with any POSIX shell tool or C++ project\n\n---\n\n## 🛠️ Usage\n\nJust include the header and go:\n\n```cpp\n#include \u003cStrUI.hpp\u003e   // path relative to your project\n#include \u003ciostream\u003e\n\nint main() {\n    std::cout \u003c\u003c strui::width(\"\\033[31m1🛑4\\033[0m\") \u003c\u003c std::endl;  // → 4\n}\n```\n\nAdd the *include* directory to your compiler flags, e.g.:\n\n```bash\ng++ -std=c++17 -I/path/to/libstrui/include example.cpp -lunistring\n```\n\n\u003e **Note:** `libunistring` is only required at *link* time when you compile the optional `.cpp` tests.  \n\u003e The header does `#ifdef` guards so you can keep your project header‑only if you already link `libunistring`.\n\n---\n\n## 🧩 API surface\n\n| Function                                      | Description                                   |\n|-----------------------------------------------|-----------------------------------------------|\n| `strui::width(str)`                           | Return *visual* width (columns) of `str`      |\n| `strui::height(str)`                          | Return number of *lines* in `str`             |\n| `strui::clean(str)`                           | Remove ANSI *escape sequences*                |\n| `strui::split(str, sep)`                      | Vector‑split `str` on `sep`                   |\n| `strui::join(str, sep = \"\")`                  | Return merged `std::string` (optional `sep`)  |\n| `strui::repeat(count, str, sep = \"\")`         | Repeat `str` `count` times (optional `sep`)   |\n| `strui::count(str, value)`                    | Count occurrences of `value` in `str`         |\n\n\u003e `Display width` is measured in `columns`, of `characters` or `strings`, when output to a device that uses `non-proportional fonts`.  \n\u003e Note that for some rarely used characters the actual `fonts` or `terminal emulators` can use a different `width`. There is no mechanism for communicating the `display width` of `characters` across a Unix pseudo-terminal (`tty`).  \n\u003e Also, there are scripts with complex rendering, like the `Indic` scripts. For these scripts, there is no such concept as `non-proportional fonts`. Therefore the results of these functions usually work fine on most scripts and on most `characters` but can fail to represent the actual `display width`.  \n\u003e 📚 See [libunistring documentation – Display width \u003cuniwidth.h\u003e](https://www.gnu.org/software/libunistring/manual/libunistring.html#uniwidth_002eh) for details on how display width is computed.\n\n---\n\n## 🧪 Test\n\nNo build is needed to *use* the library ✌️.\n\nBut you can build and run the library *test program*:\n\n```bash\n# run unit tests locally + inside an Ubuntu container (requires Docker)\nsh tests/run.sh\n```\n\n---\n\n## 📦 Dependencies\n\n- [`libunistring`](https://www.gnu.org/software/libunistring/) ≥ 1.1 (link‑time only)\n- Any **C++17** compiler (`g++`, `clang++`, …)\n\n---\n\n## 📁 Project structure\n\n```\nlibstrui/\n├── LICENCE.txt\n├── README.md\n├── include/\n│   └── strui.hpp\n└── tests/\n    ├── run.sh\n    ├── Makefile\n    ├── test.cpp\n    └── Dockerfile\n```\n\n---\n\n## 👤 Author\n\nMade with ❤️ by [@guillaumeast](https://github.com/guillaumeast)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguillaumeast%2Flibstrui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguillaumeast%2Flibstrui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguillaumeast%2Flibstrui/lists"}