make numbers culture invariant in document builder

decimal numbers were dependent on the current thread culture for the output file. this meant values like '70.679' were output as '70,679' for cultures using a comma rather than period separator for the floating point (i.e. the whole world). this resulted in the file displaying incorrectly.
This commit is contained in:
Eliot Jones
2020-02-20 13:06:12 +00:00
parent 848d687910
commit c635b919d2

View File

@@ -2,6 +2,7 @@
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using Core;
@@ -290,7 +291,7 @@
}
else
{
var bytes = OtherEncodings.StringAsLatin1Bytes(number.Data.ToString("G"));
var bytes = OtherEncodings.StringAsLatin1Bytes(number.Data.ToString("G", CultureInfo.InvariantCulture));
outputStream.Write(bytes, 0, bytes.Length);
}
@@ -339,7 +340,7 @@
private static void WriteInt(int value, Stream outputStream)
{
var bytes = OtherEncodings.StringAsLatin1Bytes(value.ToString("G"));
var bytes = OtherEncodings.StringAsLatin1Bytes(value.ToString("G", CultureInfo.InvariantCulture));
outputStream.Write(bytes, 0, bytes.Length);
}
@@ -350,7 +351,7 @@
private static void WriteLong(long value, Stream outputStream)
{
var bytes = OtherEncodings.StringAsLatin1Bytes(value.ToString("G"));
var bytes = OtherEncodings.StringAsLatin1Bytes(value.ToString("G", CultureInfo.InvariantCulture));
outputStream.Write(bytes, 0, bytes.Length);
}