| Crates.io | namecase |
| lib.rs | namecase |
| version | 0.1.0 |
| created_at | 2025-11-25 03:39:26.561922+00 |
| updated_at | 2025-11-25 03:39:26.561922+00 |
| description | A tool for converting names to proper case with intelligent handling of special naming conventions. |
| homepage | https://github.com/gravitrnic/namecase-rs |
| repository | https://github.com/gravitrnic/namecase-rs |
| max_upload_size | |
| id | 1949145 |
| size | 56,684 |
A Rust library for converting names to proper case with intelligent handling of special naming conventions.
use namecase::{namecase, NamecaseOptions};
fn main() {
// Simple usage with default options
let name = namecase("JOHN DOE", NamecaseOptions::default());
println!("{}", name); // Output: "John Doe"
// Handle special cases
println!("{}", namecase("MCCONNELL", NamecaseOptions::default())); // "McConnell"
println!("{}", namecase("MACDONALD", NamecaseOptions::default())); // "MacDonald"
println!("{}", namecase("HENRY VIII", NamecaseOptions::default())); // "Henry VIII"
}
use namecase::{namecase, NamecaseOptions};
fn main() {
let options = NamecaseOptions {
// Preserve mixed-case input (skip processing if already mixed)
enable_preserve_mixed: true,
// Allow lowercase at start (e.g. "von Trapp" instead of "Von Trapp")
enable_lowercase_start: true,
// Disable specific features if needed
disable_hebrew: false,
disable_spanish: false,
disable_roman_numerals: false,
disable_postnominal: false,
};
println!("{}", namecase("von Neumann", options));
}
Process names from the command line:
# Basic usage
cargo run -- "JOHN DOE"
# Output: John Doe
# Preserve mixed case input
cargo run -- --enable-preserve-mixed "John Smith"
# Output: John Smith
# Allow lowercase start (preserves prefixes like "von", "van", "de")
cargo run -- --enable-lowercase-start "von Neumann"
# Output: von Neumann
--enable-preserve-mixed: Skip processing if input is already mixed case
--enable-lowercase-start: Allow lowercase at start of name
--disable-hebrew: Disable Hebrew "ben"/"bat" prefix handling
--disable-spanish: Disable Spanish "el"/"la"/"y" capitalization
--disable-roman-numerals: Disable Roman numeral uppercasing
--disable-postnominal: Disable post-nominal initials preservation
The naming rules are derived from the Lingua::EN::NameCase Perl module, which is licensed under the Artistic License 2.0. No affiliation or endorsement is implied.
This project is dual-licensed under either of:
LICENSE-MIT)LICENSE-APACHE)You may choose either license.
Provenance note: Portions of this repository were generated with the help of AI tooling under the direction of the repository maintainer. Review and verify any third-party data or content included for suitability in your use case.