public static void Dump(IByteMemory bytes, int off, int len) { int lPos = (off & ~0x0F); int lEnd = off + len; while (lPos < lEnd) { Console.WriteLine(DumpLine(bytes, lPos, off, lEnd)); lPos += 16; } }
public static string DumpLine(IByteMemory bytes, int lBegin, int dBegin, int dEnd) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(ToHex(lBegin, 6)); sb.Append(" : "); int lEnd = lBegin + 16; for (int i = lBegin; i < lEnd; ++i) { if (i < dBegin || i >= dEnd) sb.Append(" "); else { sb.Append(ToHex(bytes[i], 2)); sb.Append(" "); } } sb.Append(": "); for (int i = lBegin; i < lEnd; ++i) { if (i < dBegin || i >= dEnd) sb.Append(" "); else { byte b = bytes[i]; if (b < 32 || b > 126) sb.Append("."); else sb.Append((char)b); } } return sb.ToString(); }