#homoglyphs #moderation #unicode #security #confusable

decancer

A library that removes common unicode confusables/homoglyphs from strings

31 stable releases

3.3.3 Jul 16, 2025
3.3.0 May 29, 2025
3.2.8 Oct 29, 2024
3.2.3 Jul 1, 2024
1.4.1 Jul 16, 2022

#95 in Text processing

Download history 3799/week @ 2025-09-24 6010/week @ 2025-10-01 3675/week @ 2025-10-08 3330/week @ 2025-10-15 3524/week @ 2025-10-22 4223/week @ 2025-10-29 3930/week @ 2025-11-05 4407/week @ 2025-11-12 5244/week @ 2025-11-19 5399/week @ 2025-11-26 4931/week @ 2025-12-03 6218/week @ 2025-12-10 3869/week @ 2025-12-17 2526/week @ 2025-12-24 2862/week @ 2025-12-31 4261/week @ 2026-01-07

14,800 downloads per month
Used in 21 crates (4 directly)

MIT license

96KB
2.5K SLoC

decancer npm crates.io npm downloads crates.io downloads codacy ko-fi

A library that removes common unicode confusables/homoglyphs from strings.

  • Its core is written in Rust and utilizes a form of Binary Search to ensure speed!
  • By default, it's capable of filtering 221,529 (19.88%) different unicode codepoints like:
  • Unlike other packages, this package is unicode bidi-aware where it also interprets right-to-left characters in the same way as it were to be rendered by an application!
  • Its behavior is also highly customizable to your liking!

Installation

In your Cargo.toml:

decancer = "3.3.3"

Examples

For more information, please read the documentation.

let mut cured = decancer::cure!(r"vEⓡ𝔂 𝔽𝕌Ňℕy ţ乇𝕏𝓣 wWiIiIIttHh l133t5p3/-\|<").unwrap();

assert_eq!(cured, "very funny text with leetspeak");

// WARNING: it's NOT recommended to coerce this output to a Rust string
//          and process it manually from there, as decancer has its own
//          custom comparison measures, including leetspeak matching!
assert_ne!(cured.as_str(), "very funny text with leetspeak");

assert!(cured.contains("funny"));

cured.censor("funny", '*');
assert_eq!(cured, "very ***** text with leetspeak");

cured.censor_multiple(["very", "text"], '-');
assert_eq!(cured, "---- ***** ---- with leetspeak");

Donations

If you want to support my eyes for manually looking at thousands of unicode characters, consider donating! ❤

ko-fi

Dependencies

~0–770KB
~13K SLoC