When formatting numbers, the culture is ignored in regards to the thousand separator character(s).
This appears to be because the thousand separator is hard coded as a comma.
As an example, the following code produces an incorrect result:
var format = new NumberFormat("#,##0");
var culture = new CultureInfo("da-DK");
var value = 1234567890d;
var result = format.Format(value, culture);
// result is "1,234,567,890", when it should be "1.234.567.890"
I believe the fix is to update the FormatThousandSeparator function inside Formatter.cs to the following:
static void FormatThousandSeparator(string valueString, int digit, CultureInfo culture, StringBuilder result)
{
var positionInTens = valueString.Length - 1 - digit;
if (positionInTens > 0 && (positionInTens % 3) == 0)
{
// Remove the below line:
//result.Append(",");
// Add this line instead:
result.Append(culture.NumberFormat.NumberGroupSeparator);
}
}
When formatting numbers, the culture is ignored in regards to the thousand separator character(s).
This appears to be because the thousand separator is hard coded as a comma.
As an example, the following code produces an incorrect result:
I believe the fix is to update the
FormatThousandSeparator
function inside Formatter.cs to the following: