[Mono-list] XmlConvert: Possible bug & fix - ToSingle, ToDouble using current system culture

Rodolfo Campero rodolfocampero@hotmail.com
Wed, 04 Feb 2004 00:56:29 +0000


Hi all,

I've found what I think is a bug in System.Xml.XmlConvert. The methods 
"ToSingle" and "ToDouble" are currently parsing string values using the 
current system culture, and according to the documentation, this methods 
should be locale independent.

I prepared a patch, which solves the problem.

Cheers,

Rodolfo

--- XmlConvert.cs.original	2004-02-03 21:33:31.000000000 +0100
+++ XmlConvert.cs	2004-02-03 21:47:32.000000000 +0100
@@ -247,7 +247,7 @@
				return Double.NegativeInfinity;
			if (s == "NaN")
				return Double.NaN;
-			return Double.Parse (s, floatStyle);
+			return Double.Parse (s, floatStyle, CultureInfo.InvariantCulture);
		}

		public static Guid ToGuid(string s)
@@ -286,7 +286,7 @@
				return Single.NegativeInfinity;
			if (s == "NaN")
				return Single.NaN;
-			return Single.Parse(s, floatStyle);
+			return Single.Parse(s, floatStyle, CultureInfo.InvariantCulture);
		}

		public static string ToString(Guid value)

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail