| Crates.io | unicode-rs |
| lib.rs | unicode-rs |
| version | 0.1.0 |
| created_at | 2025-06-24 02:12:32.122604+00 |
| updated_at | 2025-06-24 02:12:32.122604+00 |
| description | A comprehensive Unicode character library for Rust applications with theme support |
| homepage | https://github.com/entrepeneur4lyf/unicode-rs |
| repository | https://github.com/entrepeneur4lyf/unicode-rs |
| max_upload_size | |
| id | 1723806 |
| size | 127,225 |
A comprehensive Unicode character library for Rust applications, particularly useful for terminal applications, editors, and CLI tools that need consistent Unicode symbol support across different environments and themes.
Add this to your Cargo.toml:
[dependencies]
unicode-rs = "0.1.0"
use unicode_rs::prelude::*;
// Use symbols with different themes
let check_minimal = Symbol::Check.get_char(UnicodeTheme::Minimal); // 'v'
let check_rich = Symbol::Check.get_char(UnicodeTheme::Rich); // '✓'
let check_fancy = Symbol::Check.get_char(UnicodeTheme::Fancy); // '✅'
// Use arrows
let right_arrow = Arrow::Right.get_char(UnicodeTheme::Rich); // '→'
let up_arrow = Arrow::Up.get_char(UnicodeTheme::Rich); // '↑'
// Git symbols
let modified = GitStatus::Modified.get_char(UnicodeTheme::Rich); // '●'
let added = GitStatus::Added.get_char(UnicodeTheme::Rich); // '+'
use unicode_rs::prelude::*;
// Set global theme
set_global_config(UnicodeConfig::with_theme(UnicodeTheme::Minimal));
// Now all symbols will use the minimal theme by default
let check = get_char(&Symbol::Check, None); // 'v'
let arrow = get_char(&Arrow::Right, None); // '>'
use unicode_rs::prelude::*;
// Create config with custom overrides
let config = UnicodeConfig::with_theme(UnicodeTheme::Rich)
.with_override("custom_check", '√')
.with_fallback(); // Enable ASCII fallback for unsupported terminals
set_global_config(config);
use unicode_rs::security::*;
// Analyze text for security issues
let analysis = analyze_text("Hello\u{200B}World"); // Contains zero-width space
if analysis.risk_level >= RiskLevel::High {
println!("⚠️ Security risk detected!");
println!("{}", generate_security_report("Hello\u{200B}World"));
}
// Sanitize dangerous text
let safe_text = sanitize_text("Hello\u{200B}World\u{202E}");
assert_eq!(safe_text, "HelloWorld");
The library supports four different themes:
Check out the examples/ directory for more comprehensive usage examples:
basic_usage.rs - Simple symbol usagegit_status.rs - Git status displayfile_browser.rs - File browser with type indicatorssecurity_analysis.rs - Unicode security vulnerability detectionThis project is licensed under MIT
at your option.
Contributions are welcome! Please feel free to submit a Pull Request.