-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBytesTable.fsx
More file actions
27 lines (21 loc) · 869 Bytes
/
BytesTable.fsx
File metadata and controls
27 lines (21 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module BytesTable =
let getBytesTable (bytes : byte array) =
let sb = System.Text.StringBuilder ()
bytes
|> Array.iteri (fun i c ->
if i % 16 = 0 then
if i > 0 then sb.AppendLine () |> ignore
sb.AppendFormat("{0:x4}\t", i) |> ignore
sb.AppendFormat("{0:x2}", c) |> ignore
if i % 16 = 8 then sb.Append ' ' |> ignore
elif i % 16 = 15 then
sb.Append " " |> ignore
for i = i - 15 to i do
if bytes.[i] >= 32uy && bytes.[i] <= 126uy
then bytes.[i] |> char
else '\183'
|> sb.Append
|> ignore
if i + 1 < bytes.Length then sb.Append ' ' |> ignore
)
sb.ToString ()