PgbNameCase 1.1.2
dotnet add package PgbNameCase --version 1.1.2
NuGet\Install-Package PgbNameCase -Version 1.1.2
<PackageReference Include="PgbNameCase" Version="1.1.2" />
<PackageVersion Include="PgbNameCase" Version="1.1.2" />
<PackageReference Include="PgbNameCase" />
paket add PgbNameCase --version 1.1.2
#r "nuget: PgbNameCase, 1.1.2"
#:package PgbNameCase@1.1.2
#addin nuget:?package=PgbNameCase&version=1.1.2
#tool nuget:?package=PgbNameCase&version=1.1.2
PgbNameCase
PgbNameCase is a .NET library for properly casing personal names, handling a wide variety of edge cases such as particles (e.g., "van", "de"), prefixes (e.g., "Mc", "Mac"), apostrophes, Roman numerals, and more. It is designed to convert names from any capitalization to their correct, human-readable form.
Features
- Correctly capitalizes names with prefixes like "Mc", "Mac", "O'", etc.
- Handles names with particles (e.g., "van", "de", "von", "bin", "al").
- Supports names with apostrophes and hyphens.
- Recognizes and formats Roman numerals.
- Handles special cases and exceptions for common names.
- Null-safe and culture-invariant.
Installation
Install from NuGet:
dotnet add package PgbNameCase
Usage
using PgbNameCase;
string formatted = NameCaseFormatter.Format("john mccarthy"); // "John McCarthy"
string formatted2 = NameCaseFormatter.Format("leonardo da vinci"); // "Leonardo da Vinci"
string formatted3 = NameCaseFormatter.Format("o'connor"); // "O'Connor"
string formatted4 = NameCaseFormatter.Format("charles iii"); // "Charles III"
If you need to use custom formatted names, you can pass your own set:
var customNames = new HashSet<string> { "McCloud", "MacLeod" };
string formatted = NameCaseFormatter.Format("john mccloud", customNames); // "John McCloud"
API
NameCaseFormatter.Format: Main entry point for formatting names.FormattedNameFactory.GetNames: Provides the default set of special-case names.SpecialHandlingFactory: Contains lists of particles, prefixes, and two-letter names.
Testing
Unit tests are provided in the src/NameCase/UnitTests directory. To run the tests:
dotnet test
License
MIT License. See LICENSE.txt.
© Paul G Brown. All rights reserved.
Acknowledgements
Thanks to tamtamchik/namecase for inspiration and test cases.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.