Hex dump: Difference between revisions
Content deleted Content added
m →{{header|Julia}}: no extended ascii printing |
m →{{header|Julia}}: output syntax |
||
Line 243: | Line 243: | ||
bytes = data[begin+offset:len] |
bytes = data[begin+offset:len] |
||
fullchunksize = base == 16 ? 16 : base == 10 ? 10 : 6 |
fullchunksize = base == 16 ? 16 : base == 10 ? 10 : 6 |
||
halflen, pos = fullchunksize ÷ 2, 0 |
halflen, pos, vlen = fullchunksize ÷ 2, 0, base == 16 ? 49 : base == 10 ? 41 : 55 |
||
for chunk in Iterators.partition(bytes, fullchunksize) |
for chunk in Iterators.partition(bytes, fullchunksize) |
||
chunklen |
chunklen = length(chunk) |
||
values = map(n -> string(n, base=base, |
values = map(n -> string(n, base=base, |
||
pad = base == 16 ? 2 : base == 10 ? 3 : 8) * " ", chunk) |
pad = base == 16 ? 2 : base == 10 ? 3 : 8) * " ", chunk) |
||
Line 261: | Line 261: | ||
decdump(data; offset = 0, len = -1) = baseddump(data, 10; offset, len) |
decdump(data; offset = 0, len = -1) = baseddump(data, 10; offset, len) |
||
const tstr = b" |
const tstr = b"Rosetta Code is a programming chrestomathy site 😀." |
||
const utf16 = vcat(b"\xff\xfe", reinterpret(UInt8, transcode(UInt16, tstr |
const utf16 = vcat(b"\xff\xfe", reinterpret(UInt8, transcode(UInt16, tstr))) |
||
print("hexdump of |
print("hexdump of utf-16 string "), display(String(tstr)) |
||
hexdump(utf16) |
hexdump(utf16) |
||
print("\nxxd of |
print("\nxxd of utf-16 string "), display(String(tstr)) |
||
xxd(utf16) |
xxd(utf16) |
||
print("\ndecdump of |
print("\ndecdump of utf-16 string "), display(String(tstr)) |
||
decdump(utf16) |
decdump(utf16) |
||
</syntaxhighlight>{{out}} |
</syntaxhighlight>{{out}} |
||
<pre> |
<pre> |
||
hexdump of |
hexdump of utf-16 string "Rosetta Code is a programming chrestomathy site 😀." |
||
00000000 ff fe 52 00 6f 00 73 00 65 00 74 00 74 00 61 00 |..R.o.s.e.t.t.a.| |
00000000 ff fe 52 00 6f 00 73 00 65 00 74 00 74 00 61 00 |..R.o.s.e.t.t.a.| |
||
00000010 20 00 43 00 6f 00 64 00 65 00 20 00 69 00 73 00 | .C.o.d.e. .i.s.| |
00000010 20 00 43 00 6f 00 64 00 65 00 20 00 69 00 73 00 | .C.o.d.e. .i.s.| |
||
Line 280: | Line 281: | ||
00000060 20 00 3d d8 00 de 2e 00 | .=.....| |
00000060 20 00 3d d8 00 de 2e 00 | .=.....| |
||
xxd of |
xxd of utf-16 string "Rosetta Code is a programming chrestomathy site 😀." |
||
00000000 11111111 11111110 01010010 00000000 01101111 00000000 |..R.o.| |
00000000 11111111 11111110 01010010 00000000 01101111 00000000 |..R.o.| |
||
00000006 01110011 00000000 01100101 00000000 01110100 00000000 |s.e.t.| |
00000006 01110011 00000000 01100101 00000000 01110100 00000000 |s.e.t.| |
||
Line 300: | Line 301: | ||
00000066 00101110 00000000 |..| |
00000066 00101110 00000000 |..| |
||
decdump of |
decdump of utf-16 string "Rosetta Code is a programming chrestomathy site 😀." |
||
00000000 255 254 082 000 111 000 115 000 101 000 |..R.o.s.e.| |
00000000 255 254 082 000 111 000 115 000 101 000 |..R.o.s.e.| |
||
0000000a 116 000 116 000 097 000 032 000 067 000 |t.t.a. .C.| |
0000000a 116 000 116 000 097 000 032 000 067 000 |t.t.a. .C.| |