Giter VIP home page Giter VIP logo

leetspeak's Introduction

leetspeak

leetspeak crate leetspeak documentation build status minimum rustc 1.64.0

leetspeak is a english-to-leetspeak translation library with support for random, non-random, and custom leetspeak translation. Translations are based on wikipedia/leet#orthography. Using this library is as simple as:

use leetspeak::Level;

let text = "sphinx of black quartz, judge my vow";

// Random leetspeak translation
let random_translation = leetspeak::translate(text);

// Non-random leetspeak translation, levels 1-3
let nonrandom_translation = leetspeak::translate_with_level(text, &Level::One);
assert_eq!(nonrandom_translation, r#"5ph1nx 0f 814ck qu427z, jud93 my v0w"#);

//Custom leetspeak translation (case-insensitive). Characters not in the hashmap are not changed.
let mapping = std::collections::HashMap::from([
    ('a', String::from("4")),
    ('c', String::from("<")),
    ('e', String::from("€")),
    ('m', String::from(r#"/\/\"#)),
    ('p', String::from("|*")),
    ('s', String::from("ehs")),
    ('w', String::from("vv")),
    ('z', String::from("7_")),
]);

let custom_translation = leetspeak::translate_custom(text, mapping, &false);
assert_eq!(custom_translation, r#"ehs|*hinx of bl4<k qu4rt7_, judg€ /\/\y vovv"#);

Contributing

This is an open-source project and contributors are welcome! The repository is at github.com: leetspeak and development plans/progress are documented at github.com: leetspeak/projects. If this library is missing a feature you would like, feel free to start a discussion or develop a feature and create a pull request.

leetspeak's People

Contributors

anthonycxx avatar

Watchers

 avatar

leetspeak's Issues

`leetspeak::translate_custom` ignores case sensitivity

Describe the bug
In lib.rs, the function translate_custom() silently transforms all letters to lowercase with to_ascii_lowercase() inside of the
match statement. This prevents users from mapping upper and lowercase letters to different strings. Unit tests support this
claim.

To Reproduce
The following code demonstrates the problem:

let text = "Say";
let mapping = std::collections::HashMap::from([
    ('S', String::from("$")),
    ('s', String::from("5")),
    ('a', String::from("4")),
]);

let translation = leetspeak::translate_custom(text, mapping);
assert_eq!(translation, "$4y");  //fails! `translate_custom()` changed 'S' to 's', which mapped it to '5' instead of '$'

Expected behavior
translate_custom() should respect the case sensitivity of the custom mapping, not silently ignore it.

Resolution
Change &c.to_ascii_lowercase() to &c, removing the .to_ascii_lowercase()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.