Help with hex
am 04.04.2009 01:07:46 von Barry Brevik
I am running Active Perl 5.8.8 on Windows and am writing a data
conversion app into which I want to build some debug routines.
To that end, I want to add a routine to take any string and display it
as hex numbers.
The string can be anywhere from 0 (zero) to over 1,000 characters and
can contain any byte value from 00 to ff.
I want to do this without adding the overhead of printf or sprintf to my
program. Has anyone out there done this before?
Barry Brevik
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Help with hex
am 04.04.2009 02:21:07 von Williamawalters
--===============1822770776==
Content-Type: multipart/alternative;
boundary="part1_cda.48d8fb29.370801f3_boundary"
--part1_cda.48d8fb29.370801f3_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
hi barry --
In a message dated 4/3/2009 6:08:37 PM Eastern Standard Time,
BBrevik@StellarMicro.com writes:
> To that end, I want to add a routine to take any string and display it
> as hex numbers.
> The string can be anywhere from 0 (zero) to over 1,000 characters and
> can contain any byte value from 00 to ff.
the unpack() function is your friend in this situation, and specifically
the 'C*' unpack template specifier. after you have unpack()-ed the
string to an array (and an array of 1000 bytes is not terribly big), it
is just a matter of printing the array in the format you find most
helpful.
> I want to do this without adding the overhead of printf or sprintf to
> my program.
i am not sure what you mean by this. the printf() and sprintf()
functions are part of the perl dll and cannot be removed without
re-compilation, which i assume you have not done since a lot of
stuff would break if you did.
can you be more specific on this point?
br -- bill walters
**************
Hurry! April 15th is almost here. File your Federal taxes FREE
with TaxACT.
(http://pr.atwola.com/promoclk/100126575x1220714320x12013676 38/aol?redir=http:%2F%2Fwww.taxact.com%2F08tax.asp%3Fsc%3D08 4102950001%26p%3D82)