PgbNameCase 1.1.2

dotnet add package PgbNameCase --version 1.1.2
                    
NuGet\Install-Package PgbNameCase -Version 1.1.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PgbNameCase" Version="1.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PgbNameCase" Version="1.1.2" />
                    
Directory.Packages.props
<PackageReference Include="PgbNameCase" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PgbNameCase --version 1.1.2
                    
#r "nuget: PgbNameCase, 1.1.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PgbNameCase@1.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PgbNameCase&version=1.1.2
                    
Install as a Cake Addin
#tool nuget:?package=PgbNameCase&version=1.1.2
                    
Install as a Cake Tool

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

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
1.1.2 231 7/16/2025
1.1.1 234 5/16/2025
1.0.6 196 5/8/2025
1.0.5 190 5/7/2025
1.0.4 192 5/7/2025
1.0.3 131 5/2/2025
1.0.2 200 5/2/2025
1.0.1 198 5/1/2025
1.0.0 194 4/30/2025