Unicode-safe text cleaning & normalization for Rust.
Strip invisible characters, normalize typography, and enforce consistent formatting for text sourced from web scraping, user input, or LLMs.
This crate is a Rust rewrite and expansion of humanize-ai-lib by Nordth.
Add the Rust library crate:
[dependencies]
rehuman = "0.2.0" # replace with the latest published versionInstall CLI binaries (rehuman, ishuman):
cargo install rehumanOr use it from Python: the bindings are on PyPI as
rehuman:
pip install rehumanSee python/README.md for supported platforms and the Python API.
Click to Expand: Build from Source
For the latest version(s), clone this repo and run cargo install --path .:
git clone https://github.com/pszemraj/rehuman.git
cd rehuman
cargo install --path .Binaries will be installed to ~/.cargo/bin by default.1
use rehuman::{clean, humanize};
let cleaned = clean("Hello\u{200B}there"); // -> "Hellothere"
let humanized = humanize("“Quote”—and…more"); // -> "\"Quote\"-and...more"use rehuman::clean;
// Default behavior removes emoji
let cleaned = clean("Thanks 👍"); // -> "Thanks"By default, keyboard-only mode emits ASCII-safe output.
Non-ASCII text is normalized/transliterated when feasible: Latin diacritics
fold (café -> cafe), common symbols map to ASCII equivalents
(→ -> ->, ≠ -> !=, • -> -, © -> (c), ✅ -> [x]), and Greek
letters spell out to their names (λ -> lambda); other unmappable characters
(emoji, letter scripts like CJK or Cyrillic) are removed, never romanized.
Tune this with --non-ascii-policy, --extended-keyboard, and
--preserve-joiners (details in docs/api.md
and docs/cli.md).
For docs/source files where Unicode glyphs matter (for example box-drawing diagrams),
use the CLI with --preset code-safe; it keeps glyphs, ellipses, and emoji while
still normalizing typographic quotes and dashes.
Primary docs by concern:
- Rust API semantics (defaults, options, presets, stats, errors): docs/api.md
- CLI flags, modes, config, and exit behavior: docs/cli.md
- Usage recipes: docs/examples.md
- Python package (
pip install rehuman): python/README.md - Roadmap and development notes: docs/development.md
For CLI help at runtime: rehuman --help and ishuman --help.
MIT
Footnotes
-
You may need to add
~/.cargo/binto yourPATHif it is not already there; addexport PATH="$HOME/.cargo/bin:$PATH"to your shell profile (.bashrc,.zshrc, etc.). ↩