Diacritics 4.0.12-pre

This is a prerelease version of Diacritics.
dotnet add package Diacritics --version 4.0.12-pre
                    
NuGet\Install-Package Diacritics -Version 4.0.12-pre
                    
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="Diacritics" Version="4.0.12-pre" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Diacritics" Version="4.0.12-pre" />
                    
Directory.Packages.props
<PackageReference Include="Diacritics" />
                    
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 Diacritics --version 4.0.12-pre
                    
#r "nuget: Diacritics, 4.0.12-pre"
                    
#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.
#addin nuget:?package=Diacritics&version=4.0.12-pre&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Diacritics&version=4.0.12-pre&prerelease
                    
Install as a Cake Tool

Diacritics.NET

Version Downloads Buy Me a Coffee

Diacritics are used across many languages in order to change the sound-values of the letters to which they are added. In software development, diacritics often have to be replaced with non-diacritics, e.g. to improve usability of user input. Diacritics.NET is a basic mapper between diacritic characters an non-diacritic characters.

Download and Install Diacritics

This library is available on NuGet: https://www.nuget.org/packages/Diacritics/ Use the following command to install Diacritics using NuGet package manager console:

PM> Install-Package Diacritics

You can use this library in any .Net project which is compatible to PCL (e.g. Xamarin Android, iOS, Windows Phone, Windows Store, Universal Apps, etc.)

API Usage

Replace diacritic characters

The most common use case of this library is to find and replace diacritic characters in a given string. RemoveDiacritics is a string extension method which returns a diacritics-free string.

// Arrange
const string InputString = "Je veux aller à Saint-Étienne";

// Act
string removeDiacritics = InputString.RemoveDiacritics();

// Assert
removeDiacritics.Should().Be("Je veux aller a Saint-Etienne");

Find diacritic characters

The most common use case of this library is to detect and remove diacritic characters from a given string. If you just want to check whether a string contains diacritics, use the string extensions method HasDiacritics.

// Arrange
const string InputString = "Je veux aller à Saint-Étienne";

// Act
bool hasDiacritics = InputString.HasDiacritics();

// Assert
hasDiacritics.Should().BeTrue();

Using IDiacriticsMapper with IoC

The example shown above uses extension methods which use a default implementation of IDiacriticsMapper, namely type DefaultDiacriticsMapper. If you're using an IoC container, you can register IDiacriticsMapper either with the provided DefaultDiacriticsMapper or with your own implementation of IDiacriticsMapper.

Add custom diactrics mappings

Diacritics is extensible. You can write your own language accent by implementing IAccentMapping (or AccentMapping base class). DiacriticsMapper accepts any IAccentMapping type at construction time. You are highly welcome to contribute to this library. Just create a fork, commit your changes and create a pull request.

TODO: Add/Remove methods for adding/removing accents at runtime.

Options

You can pass DiacriticsOptions into methods like RemoveDiacritics or HasDiacritics. Following properties can be set:

Property Description
Decompose IAccentMapping provides a property IDictionary<char, MappingReplacement> Mapping which defines the actual mappings between a character and a MappingReplacement. The MappingReplacement can be setup with the properties Base, Decompose and DecomposeTitle. In most languages, there is no need to set Decompose and DecomposeTitle properties. Decomposition is needed e.g. in German language to decompose the eszett character ß to ss. If the option is set to Decompose = true, the diacritics mapper uses the Decompose and DecomposeTitle values instead of the Base value for diacritics replacements.

Benchmark Tests

Testversion

4.0.10-pre

Benchmark Environment
BenchmarkDotNet v0.15.2, macOS Sequoia 15.5 (24F74) [Darwin 24.5.0]
Apple M3 Max, 1 CPU, 14 logical and 14 physical cores
.NET SDK 9.0.301
[Host]   : .NET 9.0.6 (9.0.625.26613), Arm64 RyuJIT AdvSIMD
ShortRun : .NET 9.0.6 (9.0.625.26613), Arm64 RyuJIT AdvSIMD

Job=ShortRun  IterationCount=3  LaunchCount=1  
WarmupCount=3
Benchmark Results
Method Mean Error StdDev Rank Gen0 Gen1 Gen2 Allocated
RemoveDiacritics_100kWords 404.2 us 114.19 us 6.26 us 1 83.0078 83.0078 83.0078 265.13 KB
RemoveDiacritics_1mWords 403.7 us 35.59 us 1.95 us 1 83.0078 83.0078 83.0078 264.46 KB

Legend

  • Mean : Arithmetic mean of all measurements.
  • Error : Half of 99.9% confidence interval.
  • StdDev : Standard deviation of all measurements.
  • Rank : Relative position of current benchmark mean among all benchmarks (Arabic style).
  • 1 ns : 1 Nanosecond (0.000000001 sec).

License

This project is offered under a dual license:

  • Free for non-commercial use, including private and educational purposes.
  • Commercial use requires a license, please support the project by making a one-time donation of $50+ via https://buymeacoffee.com/thomasgalliker.

Recurring or more generous sponsorships are sincerely appreciated and help sustain ongoing development. Thank you for your support! If you have any questions about licensing, feel free to contact Thomas Galliker.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 is compatible.  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. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.2 is compatible.  netstandard1.3 was computed.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Windows Phone wpa81 was computed. 
Windows Store netcore451 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.6.2

    • No dependencies.
  • .NETStandard 1.2

  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (10)

Showing the top 5 NuGet packages that depend on Diacritics:

Package Downloads
Jellyfin.Extensions

Package Description

Dialogs

Chatbot dll

SunamoFileSystem

Overall working with filesystem

SunamoDevCode

Another code mainly for working with C# in all ways. Will be in future merged with SunamoCode and SunamoCSharp.

SunamoCollections

Working with non-generic collections

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Diacritics:

Repository Stars
jellyfin/jellyfin
The Free Software Media System - Server Backend & API
Version Downloads Last Updated
4.0.12-pre 41 6/25/2025
4.0.10-pre 43 6/25/2025
4.0.9-pre 39 6/25/2025
4.0.6-pre 42 6/24/2025
4.0.5-pre 42 6/24/2025
4.0.4-pre 68 6/20/2025
4.0.2-pre 78 6/20/2025
4.0.1-pre 80 6/20/2025
3.4.0-pre 331 4/9/2025
3.3.31-pre 1,700 10/6/2024
3.3.29 442,623 4/25/2024
3.3.28-pre 2,441 3/11/2024
3.3.27 96,832 1/14/2024
3.3.26-pre 363 1/14/2024
3.3.20-pre 6,516 5/27/2023
3.3.19-pre 691 4/18/2023
3.3.18 230,658 3/19/2023
3.3.17-pre 914 12/31/2022
3.3.16-pre 704 12/21/2022
3.3.15-pre 702 12/18/2022
3.3.14 358,691 4/27/2022
3.3.13-pre 757 4/17/2022
3.3.12-pre 750 4/17/2022
3.3.11-pre 14,465 1/9/2022
3.3.10 478,356 11/11/2021
3.3.9-pre 818 11/11/2021
3.3.8-pre 782 11/11/2021
3.3.7-pre 776 11/11/2021
3.3.6-pre 823 11/11/2021
3.3.4 38,013 10/7/2021
3.3.3-pre 809 10/7/2021
3.2.21207.2-pre 917 7/26/2021
3.1.20334.1-pre 7,259 11/29/2020
3.1.20333.3-pre 971 11/28/2020
3.0.20116.1-pre 3,696 4/25/2020
2.1.20116.2-pre 1,000 4/25/2020
2.1.20036.1 406,196 2/4/2020
2.1.20017.2-pre 1,021 1/17/2020
2.1.19293.1 64,849 10/20/2019
2.1.19292.2-pre 1,085 10/19/2019
2.1.19292.1-pre 1,056 10/19/2019
2.1.19291.8-pre 1,109 10/18/2019
2.1.19291.6-pre 1,076 10/18/2019
2.1.19286.1-pre 1,085 10/13/2019
2.1.19240.1-pre 1,115 8/28/2019
2.0.19240.3 30,548 8/28/2019
2.0.19240.2-pre 1,168 8/28/2019
2.0.19117.1-pre 1,366 4/27/2019
2.0.18316.1 97,620 11/12/2018
2.0.18311.1 1,618 11/7/2018
2.0.18308.2-pre 1,354 11/4/2018
2.0.18308.1-pre 1,374 11/4/2018
2.0.18282.1 7,506 10/9/2018
2.0.18281.2-pre 1,401 10/8/2018
2.0.18281.1-pre 1,407 10/8/2018
1.0.8-pre1 1,510 9/5/2018
1.0.7 77,343 6/13/2018
1.0.7-pre2 1,575 6/11/2018
1.0.7-pre1 1,550 6/11/2018
1.0.6 8,703 2/21/2018
1.0.5 3,541 6/8/2017
1.0.5-pre3 1,657 4/7/2017
1.0.5-pre2 1,627 4/7/2017
1.0.5-pre1 1,596 4/7/2017
1.0.4 11,775 3/24/2017
1.0.4-pre2 1,676 3/22/2017
1.0.4-pre1 1,774 12/13/2016
1.0.3 3,640 12/13/2016
1.0.3-pre3 1,715 12/13/2016
1.0.3-pre2 1,704 4/4/2016
1.0.3-pre1 1,721 4/4/2016
1.0.2 19,890 1/28/2016
1.0.1 1,912 12/16/2015
1.0.0 2,186 12/16/2015
1.0.0-pre1 1,782 12/16/2015

4.0
- Use cached StringBuilder instances to improve memory usage and reduce garbage collection pressure.
- Remove unsupported target frameworks, update dependencies, maintenance and cleanup.
- Add IDiacriticsMapper.Current (for net7.0+ and netstandard2.1+).

3.2
- Bug fixes and performance improvements.

3.1
- Bug fixes and performance improvements.

3.0
- New portuguese accents.
- Continuous improvement, new diacritics mappings.
- Bug fixes and performance improvements.

2.1.0
- Performance improvements in RemoveDiacritics.
- New method StaticDiacritics.SetDefaultMapper to replace the default IDiacriticsMapper.
- Add vietnamese mappings.

2.0.0
- Refactoring to NetStandard + NET 4.5.2.
- Several bug fixes + new diacritics added.

1.0.8
- Add Turkish ı mapping to i.

1.0.7
- Support for .Net Standard 1.0.
- Add Icelandic ð mapping to o.

1.0.6
- Add Spanish ñ mapping to n.

1.0.5
- Add support for combined cedilla characters.
- Fix German ß mapping to ss.

1.0.4
- Add .Net 4.5 implementation as dedicated assembly.
- Add missing accents mappings.
- Bug fix: Russian accents mapping fixed.

1.0.3
- Bug fix: RemoveDiacritics now also removes upper case diacritic characters.
- Bug fix: Correct handling of first letter upper case characters.

1.0.2
- Improved initialization performance by factor 8.

1.0.1
- Added diacritics mappings ArabicAccentsMapping.
- Added diacritics mappings BulgarianAccentsMapping.
- Added diacritics mappings CatalanAccentsMapping.
- Added diacritics mappings CroatianAccentsMapping.
- Added diacritics mappings CzechAccentsMapping.
- Added diacritics mappings DutchAccentsMapping.
- Added diacritics mappings EnglishAccentsMapping.
- Added diacritics mappings EstonianAccentsMapping.
- Added diacritics mappings FilipinoAccentsMapping.
- Added diacritics mappings FrenchAccentsMapping.
- Added diacritics mappings GermanAccentsMapping.
- Added diacritics mappings GreekAccentsMapping.
- Added diacritics mappings HungarianAccentsMapping.
- Added diacritics mappings IcelandicAccentsMapping.
- Added diacritics mappings ItalianAccentsMapping.
- Added diacritics mappings LatvianAccentsMapping.
- Added diacritics mappings PolishAccentsMapping.
- Added diacritics mappings PortugueseAccentsMapping.
- Added diacritics mappings RomanianAccentsMapping.
- Added diacritics mappings RussianAccentsMapping.
- Added diacritics mappings SlovakianAccentsMapping.
- Added diacritics mappings SpanishAccentsMapping.
- Added diacritics mappings TurkishAccentsMapping.
- Added diacritics mappings UkarainianAccentsMapping.