Expand description
§Unicode-rs
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.
§Features
- Multiple themes: Support for Minimal (ASCII), Basic, Rich, and Fancy Unicode themes
- Categorized symbols: Organized into logical groups (arrows, blocks, shapes, git, etc.)
- Fallback support: Graceful degradation to ASCII when Unicode isn’t supported
- Global configuration: Set theme and overrides globally for your application
- Type-safe: All symbols are strongly typed enums
§Quick Start
use unicode_rs::prelude::*;
// Use with default theme (Rich)
let check = Symbol::Check.get_char(UnicodeTheme::Rich); // ✓
let arrow = Arrow::Right.get_char(UnicodeTheme::Rich); // →
// Configure globally
set_global_config(UnicodeConfig::with_theme(UnicodeTheme::Minimal));
let check_ascii = get_char(&Symbol::Check, None); // v
§Theme Comparison
Symbol | Minimal | Basic | Rich | Fancy |
---|---|---|---|---|
Check | v | ✓ | ✓ | ✅ |
Arrow Right | > | → | → | ⮕ |
Git Modified | M | ● | ● | ◐ |
§Advanced Usage
§Custom Configuration
use unicode_rs::prelude::*;
// Create a config with fallback and custom overrides
let config = UnicodeConfig::with_theme(UnicodeTheme::Rich)
.with_fallback() // Fall back to ASCII if Unicode fails
.with_override("custom_bullet", '•');
set_global_config(config);
§Terminal Compatibility
use unicode_rs::prelude::*;
// Detect terminal capabilities and choose appropriate theme
let theme = if std::env::var("TERM").unwrap_or_default().contains("xterm") {
UnicodeTheme::Rich
} else {
UnicodeTheme::Minimal
};
set_global_config(UnicodeConfig::with_theme(theme));
§Modules
symbols
- General symbols (checkmarks, exclamation, etc.)arrows
- Directional arrows and navigation symbolsblocks
- Block drawing charactersshapes
- Geometric shapesgit
- Git status and diff symbolsfile_types
- File type indicatorsui
- UI elements (borders, separators, etc.)editor
- Editor-specific symbols (cursor, selection)status
- Status indicatorssecurity
- Unicode security utilities for detecting dangerous characters
Re-exports§
pub use unicode::*;