improved dump
This commit is contained in:
parent
149a0e1850
commit
2823692b03
@ -102,7 +102,13 @@ fun ByteArray.toDumpLines(wide: Boolean = false): List<String> {
|
||||
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<String> {
|
||||
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())
|
||||
|
Loading…
Reference in New Issue
Block a user