There are not much to say other than the usual missing argument null check:
It is valid to write the following:
string test = null;
test.RemoveDuplicateChars();
and RemoveDuplicateChars
will be called with a null
for the this
argument text
. Therefore you'll have to test for null
:
public static string RemoveDuplicateChars(
this string text, Func<string, string> normalizer = null)
{
if (string.IsNullOrWhiteSpace(text) == null)
return text;
...
or throw an exception...
The default initialization of normalizer
could be a little less verbose:
normalizer = normalizer ?? ((x) => x.Normalize());
A minor detail: Angstrom and Å: is also represented by \u00C5
, which your code interprets as equal to Angstrom, but MS Word interprets them as different when using its Find-function?
There are not much to say other than the usual missing argument null check:
It is valid to write the following:
string test = null;
test.RemoveDuplicateChars();
and RemoveDuplicateChars
will be called with a null
for the this
argument text
. Therefore you'll have to test for null
:
public static string RemoveDuplicateChars(
this string text, Func<string, string> normalizer = null)
{
if (string.IsNullOrWhiteSpace(text))
return text;
...
or throw an exception...
The default initialization of normalizer
could be a little less verbose:
normalizer = normalizer ?? ((x) => x.Normalize());
A minor detail: Angstrom and Å: is also represented by \u00C5
, which your code interprets as equal to Angstrom, but MS Word interprets them as different when using its Find-function?
There are not much to say other than the usual missing argument null check:
It is valid to write the following:
string test = null;
test.RemoveDuplicateChars();
and RemoveDuplicateChars
will be called with a null
for the this
argument text
. Therefore you'll have to test for null
:
public static string RemoveDuplicateChars(
this string text, Func<string, string> normalizer = null)
{
if (text == null)
return text;
...
or throw an exception...
The default initialization of normalizer
could be a little less verbose:
normalizer = normalizer ?? ((x) => x.Normalize());
A minor detail: Angstrom and Å: is also represented by \u00C5
, which your code interprets as equal to Angstrom, but MS Word interprets them as different when using its Find-function?
There are not much to say other than the usual missing argument null check:
It is valid to write the following:
string test = null;
test.RemoveDuplicateChars();
and RemoveDuplicateChars
will be called with a null
for the this
argument text
. Therefore you'll have to test for null
:
public static string RemoveDuplicateChars(
this string text, Func<string, string> normalizer = null)
{
if (string.IsNullOrWhiteSpace(text))
return text;
...
or throw an exception...
The default initialization of normalizer
could be a little less verbose:
normalizer = normalizer ?? ((x) => x.Normalize());
A minor detail: Angstrom and Å: is also represented by \u00C5
, which your code interprets as equal to Angstrom, but MS Word interprets them as different when using its Find-function?