Fix RemoveComment(), add hex splitter
This commit is contained in:
+18
-1
@@ -12,7 +12,7 @@ namespace processor
|
|||||||
internal static string RemoveComment(string text)
|
internal static string RemoveComment(string text)
|
||||||
{
|
{
|
||||||
int idx = text.LastIndexOf("#");
|
int idx = text.LastIndexOf("#");
|
||||||
return idx > 0 ? text.Substring(0, idx) : "";
|
return idx > 0 ? text.Substring(0, idx) : text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -33,6 +33,23 @@ namespace processor
|
|||||||
yield return text.Substring(i, Math.Min(2, text.Length - i));
|
yield return text.Substring(i, Math.Min(2, text.Length - i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static IEnumerable<string> Split4(this string text)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < text.Length; i += 4)
|
||||||
|
yield return text.Substring(i, Math.Min(4, text.Length - i));
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string[] Split1(this string text)
|
||||||
|
{
|
||||||
|
char[] a = text.ToCharArray();
|
||||||
|
string[] r = new string[text.Length];
|
||||||
|
for (int i = 0; i < text.Length; i++)
|
||||||
|
{
|
||||||
|
r[i] = a[i].ToString();
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
internal static string ToBin(this int value) => Convert.ToString(value, 2).PadLeft(8, '0');
|
internal static string ToBin(this int value) => Convert.ToString(value, 2).PadLeft(8, '0');
|
||||||
|
|
||||||
internal static string ToHex(this int value) => Convert.ToString(value, 16);
|
internal static string ToHex(this int value) => Convert.ToString(value, 16);
|
||||||
|
|||||||
Reference in New Issue
Block a user