Diacritics.NET
Diacritics.NET copied to clipboard
Add overloads to RemoveDiacritics and IsDiacritics extension methods to pass a IDiacriticsMapper
If you want to use the extension methods of the library you have to register a global default diacritics mapper. This is not very pure and it does not allow to have different mappings for different strings without switching the global mapper.
StaticDiacritics.SetDefaultMapper(() =>
new DiacriticsMapper(
new MyGermanAccentMapping(),
new GermanAccentsMapping(),
new ItalianAccentsMapping(),
new ArabicAccentsMapping()
)
);
"Thöni".RemoveDiacritics() // "Thoeni"
The current "pure" approach is to instantiate a DiacriticsMapper with accent mappings and use the methods form this instance.
var myMapper = new DiacriticsMapper(
new MyGermanAccentMapping(),
new GermanAccentsMapping(),
new ItalianAccentsMapping(),
new ArabicAccentsMapping());
myMapper.RemoveDiacritics() // "Thoeni"
This is fine. But it would be convenient to have an overload for the extensions methods where the mapper (or single accent mappings) could be passed:
"Thöni".RemoveDiacritics(myMapper) // "Thoeni"
or simply as a params array:
"Thöni".RemoveDiacritics(new MyGermanAccentMapping()) // "Thoeni"