From ffa044d4db2447f7004601a8a6ca845c61daee5b Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Tue, 10 May 2016 22:21:23 -0700 Subject: [PATCH] Fix String->Int conversion with spaces in middle Replace instead of trim, then trim. --- Misc/Util.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Misc/Util.cs b/Misc/Util.cs index 36cedfeb9..1702d2dda 100644 --- a/Misc/Util.cs +++ b/Misc/Util.cs @@ -184,11 +184,13 @@ internal static uint rnd32() // Data Retrieval internal static int ToInt32(string value) { - return string.IsNullOrWhiteSpace(value) ? 0 : int.Parse(value.Trim(' ', '_')); + string val = value?.Replace(" ", "").Replace("_", "").Trim(); + return string.IsNullOrWhiteSpace(val) ? 0 : int.Parse(val); } internal static uint ToUInt32(string value) { - return string.IsNullOrWhiteSpace(value) ? 0 : uint.Parse(value.Trim(' ', '_')); + string val = value?.Replace(" ", "").Replace("_", "").Trim(); + return string.IsNullOrWhiteSpace(val) ? 0 : uint.Parse(val); } internal static uint getHEXval(string s) {