Can I format an Erlang binary so that each byte is written in hex? I.e.,
> io:format(???, [<<255, 16>>]).
<>
This hasn’t seen any action for a while, but all of the prior solutions seem overly convoluted. Here’s what, for me, seems much simpler:
[begin if N < 10 -> 48 + N; true -> 87 + N end end || <> <= Bin]
If you prefer it expanded a bit:
[begin
if
N < 10 ->
48 + N; % 48 = $0
true ->
87 + N % 87 = ($a - 10)
end
end || <> <= Bin]