Hex dump: Difference between revisions

m
→‎{{header|Julia}}: adjust display with specified length argument
m (→‎{{header|Julia}}: adjust display with specified length argument)
Line 488:
 
=={{header|Julia}}==
<syntaxhighlight lang="julia">function baseddump(io::IO, data::Vector{UInt8}; base = 16, offset = 0, len = -1, displayadjust = 0)
@assert 2 <= base <= 16 "display base $base not supported"
lendatastop = len < 0 ? length(data) : min(offset + len - 1, length(data))
bytes = data[begin+offset:len+offsetdatastop]
fullchunksize = base == 16 ? 16 : base > 8 ? 10 : base > 4 ? 8 : 6
padsize = base == 16 ? 2 : base == 2 ? 8 : base > 7 ? 3 : base > 3 ? 4 : 5
Line 505:
end
s2 = prod(map(n -> n < 128 && isprint(Char(n)) ? Char(n) : '.', chunk))
println(io, string(pos, base = 16, pad = 8) * " " * rpad(s1, vl) * "|" * s2 * "|")
pos += chunklen
end
println(io, string(pos - offset - displayadjust, base = 16, pad = 8))
end
function baseddump(data; base = 16, offset = 0, len = -1)
4,108

edits