diff --git a/BinaryObjectScanner.Printing/Extensions.cs b/BinaryObjectScanner.Printing/Extensions.cs
index 20839ee4..a10a28a8 100644
--- a/BinaryObjectScanner.Printing/Extensions.cs
+++ b/BinaryObjectScanner.Printing/Extensions.cs
@@ -18,6 +18,19 @@ namespace BinaryObjectScanner.Printing
return sb.AppendLine($"{prefixString}: {valueString}");
}
+ ///
+ /// Append a line containing a UInt8[] value as a string to a StringBuilder
+ ///
+#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}");
+ }
+
///
/// Append a line containing a Int16[] value to a StringBuilder
///
diff --git a/BinaryObjectScanner.Printing/NewExecutable.cs b/BinaryObjectScanner.Printing/NewExecutable.cs
index b83f6ae8..f8979a1e 100644
--- a/BinaryObjectScanner.Printing/NewExecutable.cs
+++ b/BinaryObjectScanner.Printing/NewExecutable.cs
@@ -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();