Hex dump: Difference between revisions
m
→{{header|Julia}}: no extended ascii printing
(julia example) |
m (→{{header|Julia}}: no extended ascii printing) |
||
Line 252:
vstr *= " "^(base!=2) * join(values[begin+halflen:end])
end
cstr = prod(map(n -> n < 128 && isprint(Char(n)) ? Char(n) : '.', chunk))
println(string(pos, base= 16, pad = 8) * " " * rpad(vstr, vlen) * "|" * cstr * "|")
pos += fullchunksize
Line 261:
decdump(data; offset = 0, len = -1) = baseddump(data, 10; offset, len)
const
const utf16 = vcat(b"\xff\xfe", reinterpret(UInt8, transcode(UInt16, tstr[begin+2:end])))
print("hexdump of 16-bit "), display(String(
hexdump(
print("\nxxd of 16-bit "), display(String(
xxd(
print("\ndecdump of 16-bit"), display(String(
decdump(
</syntaxhighlight>{{out}}
<pre>
hexdump of 16-bit "
00000000
00000010
00000020
00000030
00000040 68 00 72 00 65 00 73 00 74 00 6f 00 6d 00 61 00 |h.r.e.s.t.o.m.a.|
00000050 74 00 68 00 79 00 20 00 73 00 69 00 74 00 65 00 |t.h.y. .s.i.t.e.|
00000060 20 00 3d d8 00 de 2e 00 | .=.....|
xxd of 16-bit "
00000000
00000006
0000000c
00000012
00000018
0000001e
00000024
0000002a
00000030 01100001 00000000 01101101 00000000 01101101 00000000 |a.m.m.|
00000036 01101001 00000000 01101110 00000000 01100111 00000000 |i.n.g.|
0000003c 00100000 00000000 01100011 00000000 01101000 00000000 | .c.h.|
00000042 01110010 00000000 01100101 00000000 01110011 00000000 |r.e.s.|
00000048 01110100 00000000 01101111 00000000 01101101 00000000 |t.o.m.|
0000004e 01100001 00000000 01110100 00000000 01101000 00000000 |a.t.h.|
00000054 01111001 00000000 00100000 00000000 01110011 00000000 |y. .s.|
0000005a 01101001 00000000 01110100 00000000 01100101 00000000 |i.t.e.|
00000060 00100000 00000000 00111101 11011000 00000000 11011110 | .=...|
00000066 00101110 00000000 |..|
decdump of 16-bit"
00000000
0000000a
00000014 111
0000001e
00000028
00000032
0000003c 032 000 099 000 104 000 114 000 101 000 | .c.h.r.e.|
00000046 115 000 116 000 111 000 109 000 097 000 |s.t.o.m.a.|
00000050 116 000 104 000 121 000 032 000 115 000 |t.h.y. .s.|
0000005a 105 000 116 000 101 000 032 000 061 216 |i.t.e. .=.|
00000064 000 222 046 000 |....|
</pre>
=={{header|Phix}}==
|