Tiny Unicode‑aware & ANSI‑aware string C++ CLI – built on top of strui-cpp-lib
.
strui
is the command‑line face of strui-cpp-lib:
think of it as a minimal, UTF‑8‑smart replacement forcut
,wc
, ortr
that 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 width
is measured incolumns
, ofcharacters
orstrings
, when output to a device that usesnon-proportional fonts
.
Note that for some rarely used characters the actualfonts
orterminal emulators
can use a differentwidth
. There is no mechanism for communicating thedisplay width
ofcharacters
across a Unix pseudo-terminal (tty
).
Also, there are scripts with complex rendering, like theIndic
scripts. 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 mostcharacters
but 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 + tests
strui/
├── 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.” 📏