Tiny Unicodeβaware & ANSIβaware string C++ CLI β built on top of strui-cpp-lib.
struiis the commandβline face of strui-cpp-lib:
think of it as a minimal, UTFβ8βsmart replacement forcut,wc, ortrthat understands emojis and ANSI escapes.
- Everything from strui-cpp-lib available at the tips of your fingers:
- clean ANSI escapes
- measure visual width / height
- split / join / repeat helpers
- substring count
- UTFβ8 aware (CJK, wide & combined emojis)
- Zero runtime dependencies β the binary is fully self-contained
- Ships as one small binary (
<50β―KB)
git clone https://github.com/guillaumeast/strui-cpp-cli.git
cd strui-cpp-cli
make installπ If you're on
Windows:
Donβt worry β we all make mistakes.
Fire upwsl, and pretend it never happened.β¨ Join us on the bright (terminal) side.
- Runtime: None
- Build-time:
libunistringβ₯ 1.1 (statically linked)- Any C++17 compiler (
g++,clang++, β¦)
| Command | Description |
|---|---|
strui width <string> |
Return visual width (columns) of string |
strui height <string> |
Return number of lines in string |
strui clean <string> |
Remove ANSI escape sequences |
strui split <string> <separator> |
Vectorβsplit string on separator |
strui join ?--separator ?<separator> <...strings...> |
Join strings with optional separator |
strui repeat <count> <string> ?<separator> |
Repeat string count times |
strui count <value> <string> |
Count occurrences of value in string |
Display widthis measured incolumns, ofcharactersorstrings, when output to a device that usesnon-proportional fonts.
Note that for some rarely used characters the actualfontsorterminal emulatorscan use a differentwidth. There is no mechanism for communicating thedisplay widthofcharactersacross a Unix pseudo-terminal (tty).
Also, there are scripts with complex rendering, like theIndicscripts. For these scripts, there is no such concept asnon-proportional fonts. Therefore the results of these functions usually work fine on most scripts and on mostcharactersbut can fail to represent the actualdisplay width.
π See libunistring documentation β Display width <uniwidth.h> for details on how display width is computed.
Requirement: Docker
Tests are run locally and inside an Ubuntu container to guarantee portability.
make test # build + testsstrui/
βββ Makefile
βββ include/strui.hpp # strui-cpp-lib header
βββ src/main.cpp # CLI implementation
βββ build/ # autogenerated binary (can be .gitignored)
βββ tests/
βββ volume/ # auto-generated at runtime by `run.sh` (can be .gitignored)
βββ run.sh # test orchestrator (POSIX sh)
βββ test.sh # unit tests (POSIX sh)
βββ Dockerfile # ubuntu image description for portability tests
βMeasure what you see β not what you store.β π