decancer npm crates.io npm downloads crates.io downloads code style: prettier Build Status license BLAZINGLY FAST!!!

A tiny package that removes common unicode confusables/homoglyphs from strings.

Installation

Rust (v1.64 or later)

In your Cargo.toml:

toml decancer = "1.6.5"

JavaScript (Node.js)

In your shell:

console $ npm install decancer

In your code (CommonJS):

js const decancer = require('decancer')

In your code (ESM):

js import decancer from 'decancer'

JavaScript (Browser)

In your code:

```html

```

C/C++

Download

Building from source

Prerequisites:

console $ git clone https://github.com/null8626/decancer.git --depth 1 $ cd decancer/bindings/native $ cargo build --release

And the binary files should be generated in the target/release directory.

Examples

note: cured output will always be in lowercase.

Rust

For more information, please read the documentation.

```rust let cured = decancer::cure("vEⓡ𝔂 𝔽𝕌Ňℕy ţ乇𝕏𝓣");

asserteq!(cured, "very funny text"); assert!(cured.contains("FuNny")); asserteq!(cured.into_str(), String::from("very funny text"));

asserteq!(decancer::cure("v̵̨̟̩͕̭̼͍̜͊̎̽̅͊̍́̏̓̕ͅe̴̡͙̳̭͚͕͕̞̦̱͊͗̈̓̑̈́̀͘ͅr̵̡̢̫̞͕͎̱͇̠͕͎̺̱̭̪̈͜ͅy̴̧̯͈̥͔̣̫̮̦̪͎̮͑̄̏̂̽͘̚͘̚͜͜͠ ̸̨̛̬͈̲̗͕̜͚̟̈̔́̾͝f̷̪̺͓̽̃̽̀̀̓̽́̾͗̋̇̀̀͐u̴͕̜̗͛̈͆̐n̸̡͙̣̙̳̥͕̥̼̪̻̪̋̀̀̽̈́͜n̷̨̗͖̗̹̜͈̗̲͔͕͉̗̻͓̟̓̽̾͗͑̾̈͜ỹ̶̧̧̩̜̹̩̩̠̦͉̮̳̦̀͛͗̒͑̅̿͌͋͠ ̴̛̠͕̥͇͉̙̯͙̠͇̝̍̃̓̆̈́̐͊̈́͘͝͠t̴̨̰̜̟͓̬͊̂̽̃͌́͂̓̊̅̃̕̚ͅȩ̵̛̬͈͔̮͙͇̫̄̽͒̊́́̀͒̚x̸̖͖̜͍̣̹̺̟̬̞̝͇̐̇̽̒͋̒̑̃̒̄̐͘͝t̸̥̅̓̉̽͑̔̑̿̇"), "very funny text"); asserteq!(decancer::cure("foo ㍴ ㎈ls console.㏒"), "foo bar calls console.log"); assert_eq!(decancer::cure("you 🆚 w3ird un1c0de ch4rs"), "you vs weird unicode chars"); ```

JavaScript (Node.js)

```js const assert = require('node:assert') const cured = decancer('vEⓡ𝔂 𝔽𝕌Ňℕy ţ乇𝕏𝓣')

assert(cured.equals('very funny text')) assert(cured.contains('funny'))

console.log(cured.toString()) // => 'very funny text'

assert(decancer("v̵̨̟̩͕̭̼͍̜͊̎̽̅͊̍́̏̓̕ͅe̴̡͙̳̭͚͕͕̞̦̱͊͗̈̓̑̈́̀͘ͅr̵̡̢̫̞͕͎̱͇̠͕͎̺̱̭̪̈͜ͅy̴̧̯͈̥͔̣̫̮̦̪͎̮͑̄̏̂̽͘̚͘̚͜͜͠ ̸̨̛̬͈̲̗͕̜͚̟̈̔́̾͝f̷̪̺͓̽̃̽̀̀̓̽́̾͗̋̇̀̀͐u̴͕̜̗͛̈͆̐n̸̡͙̣̙̳̥͕̥̼̪̻̪̋̀̀̽̈́͜n̷̨̗͖̗̹̜͈̗̲͔͕͉̗̻͓̟̓̽̾͗͑̾̈͜ỹ̶̧̧̩̜̹̩̩̠̦͉̮̳̦̀͛͗̒͑̅̿͌͋͠ ̴̛̠͕̥͇͉̙̯͙̠͇̝̍̃̓̆̈́̐͊̈́͘͝͠t̴̨̰̜̟͓̬͊̂̽̃͌́͂̓̊̅̃̕̚ͅȩ̵̛̬͈͔̮͙͇̫̄̽͒̊́́̀͒̚x̸̖͖̜͍̣̹̺̟̬̞̝͇̐̇̽̒͋̒̑̃̒̄̐͘͝t̸̥̅̓̉̽͑̔̑̿̇"), "very funny text") assert(decancer("foo ㍴ ㎈ls console.㏒"), "foo bar calls console.log") assert(decancer("you 🆚 w3ird un1c0de ch4rs"), "you vs weird unicode chars") ```

JavaScript (Browser)

```html Decancerer!!! (tm)