Whitespace fix

This commit is contained in:
Rick Falkvinge
2018-05-05 17:13:12 +02:00
parent 4b44f35605
commit 4553e42a11
2 changed files with 15 additions and 2 deletions
+4 -2
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography;
using System.Web.ExtensionMethods;
using Swarmops.Common;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
@@ -407,9 +408,10 @@ namespace Swarmops.Logic.Financial
}
// remove all known noise from the digit sequence: spaces, thousands accents, commas, periods
// remove all known noise from the digit sequence: all whitespace, thousands accents, commas, periods
input = input.Replace (" ", "").Replace ("'", "").Replace (",", "").Replace (".", "");
input = input.RemoveAllWhitespace();
input = input.Replace ("'", "").Replace (",", "").Replace (".", "");
// parse what's remaining as cents in Int64
+11
View File
@@ -1,5 +1,6 @@
using System.Globalization;
using System.IO;
using System.Linq;
namespace System.Web.ExtensionMethods
{
@@ -91,4 +92,14 @@ namespace System.Web.ExtensionMethods
}
}
}
public static class StringExtensions
{
public static string RemoveAllWhitespace(this string input)
{
return new string(input.ToCharArray()
.Where(c => !Char.IsWhiteSpace(c))
.ToArray());
}
}
}