[erlang-questions] Formatting question
Vance Shipley
vances@REDACTED
Sat Aug 4 21:58:47 CEST 2007
On Sat, Aug 04, 2007 at 09:06:23PM +0200, Burkhard Neppert wrote:
} I'd like to convert binary data to its hex string representation.
} E.g. bin2hex(<<255:16>>) -> "00FF"
2> t:bin2hex(<<255:16>>).
00FF
ok
-module(t).
-export([bin2hex/1]).
bin2hex(<<>>) ->
io:fwrite("~n");
bin2hex(<<I:8, Rest/binary>>) ->
io:fwrite("~2.16.0B", [I]),
bin2hex(Rest).
More information about the erlang-questions
mailing list