mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Change Console output to String output.
Add function to write String output to Console.
This commit is contained in:
@@ -43,14 +43,21 @@ namespace DiscImageChef
|
|||||||
{
|
{
|
||||||
public static void PrintHexArray(byte[] array, int width)
|
public static void PrintHexArray(byte[] array, int width)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(ByteArrayToHexArrayString(array, width));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ByteArrayToHexArrayString(byte[] array, int width)
|
||||||
|
{
|
||||||
|
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
int subcounter = 0;
|
int subcounter = 0;
|
||||||
for (long i = 0; i < array.LongLength; i++)
|
for (long i = 0; i < array.LongLength; i++)
|
||||||
{
|
{
|
||||||
if (counter == 0)
|
if (counter == 0)
|
||||||
{
|
{
|
||||||
Console.WriteLine();
|
sb.AppendLine();
|
||||||
Console.Write("{0:X16} ", i);
|
sb.AppendFormat("{0:X16} ", i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -66,7 +73,7 @@ namespace DiscImageChef
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.Write("{0:X2}", array[i]);
|
sb.AppendFormat("{0:X2}", array[i]);
|
||||||
|
|
||||||
if (counter == width - 1)
|
if (counter == width - 1)
|
||||||
{
|
{
|
||||||
@@ -76,8 +83,10 @@ namespace DiscImageChef
|
|||||||
else
|
else
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
Console.WriteLine();
|
sb.AppendLine();
|
||||||
Console.WriteLine();
|
sb.AppendLine();
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user