how to best convert an array containing hexadecimal values to ascii value?

2010-11-23 Thread Greg Aiken
if one dumps a windows registry section using regedit (to *.reg format)

 

the reg_sz values are listed in the following format (heres a code fragment)

 

\\DosDevices\\E:=hex:5c,00,3f,00,3f,00,5c,00,53,00,43,00,53,00,49,00,23,00
,\

 
43,00,64,00,52,00,6f,00,6d,00,26,00,56,00,65,00,6e,00,5f,00,45,00,5a,00,35,\

 
00,33,00,35,00,32,00,58,00,26,00,50,00,72,00,6f,00,64,00,5f,00,56,00,54,00,\

 
59,00,35,00,32,00,37,00,4f,00,26,00,52,00,65,00,76,00,5f,00,32,00,2e,00,30,\

 
00,42,00,23,00,35,00,26,00,33,00,36,00,65,00,35,00,39,00,37,00,32,00,26,00,\

 
30,00,26,00,30,00,30,00,30,00,23,00,7b,00,35,00,33,00,66,00,35,00,36,00,33,\

 
00,30,00,64,00,2d,00,62,00,36,00,62,00,66,00,2d,00,31,00,31,00,64,00,30,00,\

 
2d,00,39,00,34,00,66,00,32,00,2d,00,30,00,30,00,61,00,30,00,63,00,39,00,31,\

  00,65,00,66,00,62,00,38,00,62,00,7d,00

 

ive already got code that parses this info.

 

ive removed the trailing \(backslash)newline(space)(space) from the data
block so im left with a scalar containing hexadecimal values separated with
a comma.

 

ive then split this long scaler on the ',' (comma) to yield an array
containing the hex values.

 

my problem here is that I don't know the easiest 'built-in' way to convert
this list of hex values to ascii values (ascii values as in the ascii
character set for printing in human readable letters).  as in the 'char'
column of this table
http://www.hobbyprojects.com/ascii-table/images/ascii-table1.gif

 

I know chr(decimal value) will do such a conversion.  but my values in the
array are not in decimal value format.

 

and im kind of lost with pack.  ive unsuccessfully tried.

 

$ascii_string = pack(H*, @hex_array) and 

$ascii_string = pack(h*, @hex_array) 

 

but neither yields the proper output.

 

I know I could write an ultra low level code that directly converts each hex
byte to decimal, then call chr with the decimal value, but certainly that's
'too much work' in perl.

 

any help would be appreciated.

 

it would be as if were starting with 

 

@hex_array = ('5c','00','3f','00','3f','00','5c','00','53','00',.);

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: how to best convert an array containing hexadecimal values to ascii value?

2010-11-23 Thread will trillich
Dude! This one is really easy:

print hex(ff); # 255!

so @result = map{ hex } @source;

Mwa ha ha!


On Tue, Nov 23, 2010 at 3:44 PM, Greg Aiken gai...@visioninfosoft.comwrote:

  if one dumps a windows registry section using regedit (to *.reg format)



 the reg_sz values are listed in the following format (heres a code
 fragment)




 \\DosDevices\\E:=hex:5c,00,3f,00,3f,00,5c,00,53,00,43,00,53,00,49,00,23,00,\


 43,00,64,00,52,00,6f,00,6d,00,26,00,56,00,65,00,6e,00,5f,00,45,00,5a,00,35,\


 00,33,00,35,00,32,00,58,00,26,00,50,00,72,00,6f,00,64,00,5f,00,56,00,54,00,\


 59,00,35,00,32,00,37,00,4f,00,26,00,52,00,65,00,76,00,5f,00,32,00,2e,00,30,\


 00,42,00,23,00,35,00,26,00,33,00,36,00,65,00,35,00,39,00,37,00,32,00,26,00,\


 30,00,26,00,30,00,30,00,30,00,23,00,7b,00,35,00,33,00,66,00,35,00,36,00,33,\


 00,30,00,64,00,2d,00,62,00,36,00,62,00,66,00,2d,00,31,00,31,00,64,00,30,00,\


 2d,00,39,00,34,00,66,00,32,00,2d,00,30,00,30,00,61,00,30,00,63,00,39,00,31,\

   00,65,00,66,00,62,00,38,00,62,00,7d,00



 ive already got code that parses this info.



 ive removed the trailing \(backslash)newline(space)(space) from the data
 block so im left with a scalar containing hexadecimal values separated with
 a comma.



 ive then split this long scaler on the ‘,’ (comma) to yield an array
 containing the hex values.



 my problem here is that I don’t know the easiest ‘built-in’ way to convert
 this list of hex values to ascii values (ascii values as in the ascii
 character set for printing in human readable letters).  as in the ‘char’
 column of this table
 http://www.hobbyprojects.com/ascii-table/images/ascii-table1.gif



 I know chr(decimal value) will do such a conversion.  but my values in the
 array are not in decimal value format.



 and im kind of lost with pack…  ive unsuccessfully tried…



 $ascii_string = pack(“H*”, @hex_array) and

 $ascii_string = pack(“h*”, @hex_array)



 but neither yields the proper output.



 I know I could write an ultra low level code that directly converts each
 hex byte to decimal, then call chr with the decimal value, but certainly
 that’s ‘too much work’ in perl.



 any help would be appreciated.



 it would be as if were starting with



 @hex_array = (‘5c’,’00’,’3f’,’00’,’3f’,’00’,’5c’,’00’,’53’,’00’,…);

 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




-- 
Failure is not important. How you overcome it, is.
-- Nick Vujicic
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: how to best convert an array containing hexadecimal values to ascii value?

2010-11-23 Thread Greg Aiken
thanks much!  never used 'hex' before.

 

  _  

From: will trillich [mailto:will.trill...@serensoft.com] 
Sent: Tuesday, November 23, 2010 1:47 PM
To: gai...@visioninfosoft.com
Cc: perl-win32-users@listserv.activestate.com
Subject: Re: how to best convert an array containing hexadecimal values to
ascii value?

 

Dude! This one is really easy:

 

print hex(ff); # 255!

 

so @result = map{ hex } @source;

 

Mwa ha ha!

 

On Tue, Nov 23, 2010 at 3:44 PM, Greg Aiken gai...@visioninfosoft.com
wrote:

if one dumps a windows registry section using regedit (to *.reg format)

 

the reg_sz values are listed in the following format (heres a code fragment)

 

\\DosDevices\\E:=hex:5c,00,3f,00,3f,00,5c,00,53,00,43,00,53,00,49,00,23,00
,\

 
43,00,64,00,52,00,6f,00,6d,00,26,00,56,00,65,00,6e,00,5f,00,45,00,5a,00,35,\

 
00,33,00,35,00,32,00,58,00,26,00,50,00,72,00,6f,00,64,00,5f,00,56,00,54,00,\

 
59,00,35,00,32,00,37,00,4f,00,26,00,52,00,65,00,76,00,5f,00,32,00,2e,00,30,\

 
00,42,00,23,00,35,00,26,00,33,00,36,00,65,00,35,00,39,00,37,00,32,00,26,00,\

 
30,00,26,00,30,00,30,00,30,00,23,00,7b,00,35,00,33,00,66,00,35,00,36,00,33,\

 
00,30,00,64,00,2d,00,62,00,36,00,62,00,66,00,2d,00,31,00,31,00,64,00,30,00,\

 
2d,00,39,00,34,00,66,00,32,00,2d,00,30,00,30,00,61,00,30,00,63,00,39,00,31,\

  00,65,00,66,00,62,00,38,00,62,00,7d,00

 

ive already got code that parses this info.

 

ive removed the trailing \(backslash)newline(space)(space) from the data
block so im left with a scalar containing hexadecimal values separated with
a comma.

 

ive then split this long scaler on the ',' (comma) to yield an array
containing the hex values.

 

my problem here is that I don't know the easiest 'built-in' way to convert
this list of hex values to ascii values (ascii values as in the ascii
character set for printing in human readable letters).  as in the 'char'
column of this table
http://www.hobbyprojects.com/ascii-table/images/ascii-table1.gif

 

I know chr(decimal value) will do such a conversion.  but my values in the
array are not in decimal value format.

 

and im kind of lost with pack.  ive unsuccessfully tried.

 

$ascii_string = pack(H*, @hex_array) and 

$ascii_string = pack(h*, @hex_array) 

 

but neither yields the proper output.

 

I know I could write an ultra low level code that directly converts each hex
byte to decimal, then call chr with the decimal value, but certainly that's
'too much work' in perl.

 

any help would be appreciated.

 

it would be as if were starting with 

 

@hex_array = ('5c','00','3f','00','3f','00','5c','00','53','00',.);


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




-- 
Failure is not important. How you overcome it, is.
-- Nick Vujicic

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: how to best convert an array containing hexadecimal values to ascii value?

2010-11-23 Thread will trillich
Or if you want the characters themselves:

@result = map { chr( hex ) } @source;

Or as a solid string:

$s = join '', map { chr( hex ) } @source;


On Tue, Nov 23, 2010 at 3:47 PM, will trillich
will.trill...@serensoft.comwrote:

 Dude! This one is really easy:

 print hex(ff); # 255!

 so @result = map{ hex } @source;

 Mwa ha ha!


 On Tue, Nov 23, 2010 at 3:44 PM, Greg Aiken gai...@visioninfosoft.comwrote:

  if one dumps a windows registry section using regedit (to *.reg format)



 the reg_sz values are listed in the following format (heres a code
 fragment)




 \\DosDevices\\E:=hex:5c,00,3f,00,3f,00,5c,00,53,00,43,00,53,00,49,00,23,00,\


 43,00,64,00,52,00,6f,00,6d,00,26,00,56,00,65,00,6e,00,5f,00,45,00,5a,00,35,\


 00,33,00,35,00,32,00,58,00,26,00,50,00,72,00,6f,00,64,00,5f,00,56,00,54,00,\


 59,00,35,00,32,00,37,00,4f,00,26,00,52,00,65,00,76,00,5f,00,32,00,2e,00,30,\


 00,42,00,23,00,35,00,26,00,33,00,36,00,65,00,35,00,39,00,37,00,32,00,26,00,\


 30,00,26,00,30,00,30,00,30,00,23,00,7b,00,35,00,33,00,66,00,35,00,36,00,33,\


 00,30,00,64,00,2d,00,62,00,36,00,62,00,66,00,2d,00,31,00,31,00,64,00,30,00,\


 2d,00,39,00,34,00,66,00,32,00,2d,00,30,00,30,00,61,00,30,00,63,00,39,00,31,\

   00,65,00,66,00,62,00,38,00,62,00,7d,00



 ive already got code that parses this info.



 ive removed the trailing \(backslash)newline(space)(space) from the data
 block so im left with a scalar containing hexadecimal values separated with
 a comma.



 ive then split this long scaler on the ‘,’ (comma) to yield an array
 containing the hex values.



 my problem here is that I don’t know the easiest ‘built-in’ way to convert
 this list of hex values to ascii values (ascii values as in the ascii
 character set for printing in human readable letters).  as in the ‘char’
 column of this table
 http://www.hobbyprojects.com/ascii-table/images/ascii-table1.gif



 I know chr(decimal value) will do such a conversion.  but my values in the
 array are not in decimal value format.



 and im kind of lost with pack…  ive unsuccessfully tried…



 $ascii_string = pack(“H*”, @hex_array) and

 $ascii_string = pack(“h*”, @hex_array)



 but neither yields the proper output.



 I know I could write an ultra low level code that directly converts each
 hex byte to decimal, then call chr with the decimal value, but certainly
 that’s ‘too much work’ in perl.



 any help would be appreciated.



 it would be as if were starting with



 @hex_array = (‘5c’,’00’,’3f’,’00’,’3f’,’00’,’5c’,’00’,’53’,’00’,…);

 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




 --
 Failure is not important. How you overcome it, is.
 -- Nick Vujicic




-- 
Failure is not important. How you overcome it, is.
-- Nick Vujicic
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs