From 381fe658fcea68703c8233b5487cb1eaf1898de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Wed, 24 May 2017 21:04:59 +0200 Subject: [PATCH] Use culture independent ToString for converting doubles to string --- GnuPlot.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/GnuPlot.cs b/GnuPlot.cs index c183a32..b3c1ebc 100644 --- a/GnuPlot.cs +++ b/GnuPlot.cs @@ -4,6 +4,7 @@ using System.IO; using System.Threading; using System.Linq; +using System.Globalization; namespace AwokeKnowing.GnuplotCSharp { @@ -374,7 +375,7 @@ public static void SPlot(List storedPlots) public static void WriteData(double[] y, StreamWriter stream, bool flush = true) { for (int i = 0; i < y.Length; i++) - stream.WriteLine(y[i].ToString()); + stream.WriteLine(y[i].ToString(CultureInfo.InvariantCulture)); if (flush) stream.Flush(); } @@ -382,7 +383,7 @@ public static void WriteData(double[] y, StreamWriter stream, bool flush = true) public static void WriteData(double[] x, double[] y, StreamWriter stream, bool flush = true) { for (int i = 0; i < y.Length; i++) - stream.WriteLine(x[i].ToString() + " " + y[i].ToString()); + stream.WriteLine(x[i].ToString(CultureInfo.InvariantCulture) + " " + y[i].ToString(CultureInfo.InvariantCulture)); if (flush) stream.Flush(); } @@ -393,7 +394,7 @@ public static void WriteData(int ySize, double[] z, StreamWriter stream, bool fl { if (i > 0 && i % ySize == 0) stream.WriteLine(); - stream.WriteLine(z[i].ToString()); + stream.WriteLine(z[i].ToString(CultureInfo.InvariantCulture)); } if (flush) stream.Flush(); @@ -408,7 +409,7 @@ public static void WriteData(double[,] zz, StreamWriter stream, bool flush = tru { line = ""; for (int j = 0; j < n; j++) - line += zz[i, j].ToString() + " "; + line += zz[i, j].ToString(CultureInfo.InvariantCulture) + " "; stream.WriteLine(line.TrimEnd()); } @@ -423,7 +424,8 @@ public static void WriteData(double[] x, double[] y, double[] z, StreamWriter st { if (i > 0 && x[i] != x[i - 1]) stream.WriteLine(""); - stream.WriteLine(x[i] + " " + y[i] + " " + z[i]); + + stream.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0} {1} {2}", x[i], y[i], z[i])); } if (flush) stream.Flush();