mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-09-22 06:45:03 +00:00
Add byte array to encoding extension
This commit is contained in:
@@ -18,6 +18,19 @@ namespace BinaryObjectScanner.Printing
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append a line containing a UInt8[] value as a string to a StringBuilder
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, byte[] value, string prefixString, Encoding encoding)
|
||||
#else
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, byte[]? value, string prefixString, Encoding encoding)
|
||||
#endif
|
||||
{
|
||||
string valueString = (value == null ? "[NULL]" : encoding.GetString(value).Replace("\0", string.Empty));
|
||||
return sb.AppendLine($"{prefixString}: {valueString}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append a line containing a Int16[] value to a StringBuilder
|
||||
/// </summary>
|
||||
|
||||
@@ -225,7 +225,7 @@ namespace BinaryObjectScanner.Printing
|
||||
}
|
||||
#endif
|
||||
builder.AppendLine(typeAndNameString.Value.Length, " Length");
|
||||
builder.AppendLine($" Text: {(typeAndNameString.Value.Text != null ? Encoding.ASCII.GetString(typeAndNameString.Value.Text).TrimEnd('\0') : "[EMPTY]")}");
|
||||
builder.AppendLine(typeAndNameString.Value.Text, " Text", Encoding.ASCII);
|
||||
}
|
||||
}
|
||||
builder.AppendLine();
|
||||
@@ -257,7 +257,7 @@ namespace BinaryObjectScanner.Printing
|
||||
}
|
||||
|
||||
builder.AppendLine(entry.Length, " Length");
|
||||
builder.AppendLine($" Name string: {(entry.NameString != null ? Encoding.ASCII.GetString(entry.NameString).TrimEnd('\0') : "[EMPTY]")}");
|
||||
builder.AppendLine(entry.NameString, " Name string", Encoding.ASCII);
|
||||
builder.AppendLine(entry.OrdinalNumber, " Ordinal number");
|
||||
}
|
||||
builder.AppendLine();
|
||||
@@ -324,7 +324,7 @@ namespace BinaryObjectScanner.Printing
|
||||
}
|
||||
#endif
|
||||
builder.AppendLine(entry.Value.Length, " Length");
|
||||
builder.AppendLine($" Name string: {(entry.Value.NameString != null ? Encoding.ASCII.GetString(entry.Value.NameString) : "[EMPTY]")}");
|
||||
builder.AppendLine(entry.Value.NameString, " Name string", Encoding.ASCII);
|
||||
}
|
||||
builder.AppendLine();
|
||||
}
|
||||
@@ -399,7 +399,7 @@ namespace BinaryObjectScanner.Printing
|
||||
}
|
||||
|
||||
builder.AppendLine(entry.Length, " Length");
|
||||
builder.AppendLine($" Name string: {(entry.NameString != null ? Encoding.ASCII.GetString(entry.NameString) : "[EMPTY]")}");
|
||||
builder.AppendLine(entry.NameString, " Name string", Encoding.ASCII);
|
||||
builder.AppendLine(entry.OrdinalNumber, " Ordinal number");
|
||||
}
|
||||
builder.AppendLine();
|
||||
|
||||
Reference in New Issue
Block a user