Skip to content

Commit 093c3a6

Browse files
committed
Updated decimal formatting and test cases
Harmonized decimal formatting between different target platforms
1 parent 9e9957b commit 093c3a6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

QRCoder/SvgQRCode.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ private struct ImageAttributes
243243
private string CleanSvgVal(double input)
244244
{
245245
//Clean double values for international use/formats
246-
return input.ToString(System.Globalization.CultureInfo.InvariantCulture);
246+
//We use explicitly "G15" to avoid differences between .NET full and Core platforms
247+
//https://stackoverflow.com/questions/64898117/tostring-has-a-different-behavior-between-net-462-and-net-core-3-1
248+
return input.ToString("G15", System.Globalization.CultureInfo.InvariantCulture);
247249
}
248250

249251
/// <summary>

QRCoderTests/SvgQRCodeRendererTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void can_render_svg_qrcode_viewbox_mode()
6464
var svg = new SvgQRCode(data).GetGraphic(new Size(128,128));
6565

6666
var result = HelperFunctions.StringToHash(svg);
67-
result.ShouldBe("ec9a13c4484d246e3e2e0574958845c8");
67+
result.ShouldBe("56719c7db39937c74377855a5dc4af0a");
6868
}
6969

7070
[Fact]

0 commit comments

Comments
 (0)