# Wishes: hex-output

4 messages
Open this post in threaded view
|
Report Content as Inappropriate

## Wishes: hex-output

 These functions can probably be added to lists or string. to_lower(Str) ->     to_lower(Str, []). to_lower([H|T], Acc) when H>=65, H =< 90 ->     to_lower(T, [H+32|Acc]); to_lower([H|T], Acc) ->     to_lower(T, [H|Acc]); to_lower([], Acc) ->     lists:reverse(Acc). to_upper(Str) ->     to_upper(Str, []). to_upper([H|T], Acc) when H>=97, H =< 122 ->     to_upper(T, [H-32|Acc]); to_upper([H|T], Acc) ->     to_upper(T, [H|Acc]); to_upper([], Acc) ->     lists:reverse(Acc). regards, Chandru > -----Original Message----- > From: Robert Virding [mailto:rv] > Sent: 18 January 2001 10:14 > To: Erik Johansson > Cc: erlang-questions; Jouni.Ryno > Subject: Re: Wishes: hex-output > > > "Erik Johansson" writes: > > > >----- Original Message ----- > >From: > >> > >> If it's going to be late Christmas season, and one could make some > >> wishes, what about hex-output for io:format > >> > > > >Yes. I have always needed this. I use ~h and ~H. With the > patch below you > >can do: > >>  io:format("~h 0x~H 16#~h\n", [51966, 51966, 51966]). > >cafe 0xCAFE 16#cafe > >> > > Seems reasonable.  I'll add it. My only small qualm is that the > coupling ~h/~H does not mean the same thing as ~w/~W and ~p/~P, but I > suppose there is not real problem here. > > There should be probably be a matching hex-input flag for > io:fread.  I > suppose I had better do that one as well. > > Robert > > NOTICE AND DISCLAIMER: This email (including attachments) is confidential.  If you have received this email in error please notify the sender immediately and delete this email from your system without copying or disseminating it or placing any reliance upon its contents.  We cannot accept liability for any breaches of confidence arising through use of email.  Any opinions expressed in this email (including attachments) are those of the author and do not necessarily reflect our opinions.  We will not accept responsibility for any commitments made by our employees outside the scope of our business.  We do not warrant the accuracy or completeness of such information.
Open this post in threaded view
|
Report Content as Inappropriate

## Wishes: hex-output

 Or alternatively: ucase([C|Cs]) when C>=\$a,C=<\$z -> [C-32|ucase(Cs)]; % a-z ucase([C|Cs])                  -> [C|ucase(Cs)]; ucase([])                      -> []. lcase([C|Cs]) when C>=\$A,C=<\$Z -> [C+32|lcase(Cs)]; % A-Z lcase([C|Cs])                  -> [C|lcase(Cs)]; lcase([])                      -> []. capw([C|Cs]) when C>=\$a,C=<\$z  -> [C-32|lcase(Cs)]; capw(Cs)                       -> lcase(Cs). Cheers /Tobbe
Open this post in threaded view
|
Report Content as Inappropriate

## Wishes: hex-output

 What about ????? etc? Would be better to go to the functions in the OS instead. /Jakob