From 2823692b037f892ed7d77c9f67adabac9f828d24 Mon Sep 17 00:00:00 2001 From: sergeych Date: Wed, 15 Mar 2023 10:19:18 +0100 Subject: [PATCH] improved dump --- .../kotlin/net.sergeych.bintools/simple_codecs.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/net.sergeych.bintools/simple_codecs.kt b/src/commonMain/kotlin/net.sergeych.bintools/simple_codecs.kt index ae0c76e..29db24f 100644 --- a/src/commonMain/kotlin/net.sergeych.bintools/simple_codecs.kt +++ b/src/commonMain/kotlin/net.sergeych.bintools/simple_codecs.kt @@ -102,7 +102,13 @@ fun ByteArray.toDumpLines(wide: Boolean = false): List { val max: Int = kotlin.math.min(size, from + lineSize) while (from < max) { val ch = this[from++].toInt() - if (ch >= ' '.code && ch < 127) b.append(ch.toChar()) else b.append('.') + when { + ch == ' '.code -> b.append('\u25AD') + (ch > ' '.code && ch < 127) -> b.append(ch.toChar()) + else -> b.append('.') + } + if( (from % lineSize) == lineSize/2 ) + b.append("\u250A") } val remainder = from % lineSize if (remainder > 0) { @@ -128,12 +134,14 @@ fun ByteArray.toDumpLines(wide: Boolean = false): List { line.append(' ') } line!!.append((this[i].toUByte()).encodeToHex(2)) + if( i == lineSize/2) line.append(" \u250A") line.append(' ') } if (line != null) { val l = size var fill = lineSize - l % lineSize if (fill < lineSize) while (fill-- > 0) line.append(" ") + line.append(" ") val index = l - l % lineSize line.append(dumpChars(if (index < l) index else l - lineSize)) lines.add(line.toString())