-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathStringUtils.cs
33 lines (28 loc) · 957 Bytes
/
StringUtils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System.Globalization;
namespace ACUtils
{
public static class StringUtils
{
public static string Truncate(this string value, int maxLength)
{
if (string.IsNullOrEmpty(value))
{
return value;
}
return value.Length <= maxLength ? value : value.Substring(0, maxLength);
}
public static string DecodeBase64(string encodedString)
{
byte[] data = System.Convert.FromBase64String(encodedString);
return System.Text.Encoding.UTF8.GetString(data);
}
public static decimal Normalize(this decimal value)
{
return value / 1.000000000000000000000000000000000m;
}
public static string ToNormalizedString(this decimal value, string culture = "it-IT")
{
return value.Normalize().ToString(CultureInfo.CreateSpecificCulture(culture));
}
}
}