I'm using dotnet core and running a couple os tests on customized string extensions inside a docker container and it fail always, but it works well on a windows machine.
i've tryed to enforce the portuguese culture but it does not work, what am i missing here?
As example, i'm trying to remove diacritics from a string using as follows:
public static string RemoveDiacritics(this string input)
{
var normalizedString = input.Normalize(NormalizationForm.FormD);
var stringBuilder = new StringBuilder();
foreach (var c in normalizedString)
{
var unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c);
if (unicodeCategory != UnicodeCategory.NonSpacingMark)
{
stringBuilder.Append(c);
}
}
return stringBuilder.ToString().Normalize(NormalizationForm.FormC);
}
Here is the test example (NUnit)
[Test]
public void StringExtensions_RemoveDiacritics_SUCCESS()
{
string originalStr = "amahã deverá ser çábado";
string cleanStr = originalStr.RemoveDiacritics();
Assert.AreEqual("amaha devera ser cabado", cleanStr);
}
Here is the dockerfile example:
FROM mcr.microsoft.com/dotnet/sdk:3.1-focal
WORKDIR /
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
ENV TZ Europe/Lisbon
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN dpkg-reconfigure --frontend noninteractive tzdata
For better undertanding how to reproduce, i've created the following repo: https://github.com/FlavioCFOliveira/TestsOnStrings