R8 and (no) hex output ...

Matthias Lang <>
Sat Oct 20 02:13:22 CEST 2001


 > Not that I complain, but would it be possible to have ~h/~H in the 
 > io_lib for hex-output in some near future release, please. Sometimes it 

In the name of "incomplete, mostly untested code is better than none
at all", here's a patch (against R8B) I use to help avoid insanity
while debugging non-text protocols. It gives you ~h, though with
restrictions. 

Examples:
   
   11> io:fwrite("~h\n", [99999999999999999999999999999]).
   1431e0fae6d7217ca9fffffff
   ok
   13> io:fwrite("~h\n", [<<"hello world">>]).
   <(68,65,6c,6c,6f,20,77,6f,72,6c,64)>
   ok
   14> io:fwrite("~20h\n", [<<"hello world">>]). 
   <(68,65,6c,6c...)>

>From the code:

%% Hex output of integers or binaries.
%% 
%% Integer support is lame; Width, alignment and precision are
%% not allowed. Nor are negative numbers.
%%         
%% Binary support is less lame. Width is allowed, though not
%% below 7, which means you can't print <(7a)>.

Matthias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hexpatch
Type: application/octet-stream
Size: 2529 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20011020/2951a214/attachment.obj>
-------------- next part --------------



More information about the erlang-questions mailing list