Ads 468x60px

Smaller time frame always follow the bigger time frame. It's better wait be patience to enter in position than risk with BIG SL. Having strong trading discipline and taking losses when necessary is a sign of serious trading approach
Subscribe:

Labels

Saturday, August 11, 2012

BIN2HEX - SCRIPT TO CONVERT DATA FILES INTO SOURCE CODE ARRAYS


Looking for a way to convert a binary (or even a text) file into a Perl, Pascal/Delphi, C/C++, or Java source code array? For example, you may want to do this to include a GIF or other binary file directly inside your Perl CGI script, rather than reading the data from a file to reduce file access. If you're writing Windows programs, you could use the same method to store resource files in your executable files. 
 
The bin2hex.pl script will take a binary file name and output a source code array, in the specified language, necessary to recreate the input data inside a program.
 
To run the script, first make sure that you have a Perl interpreter installed on your system and download the bin2hex.pl script. Then execute the following command from your command prompt (assuming you want to convert a file named banner.gif to a Perl string):
 
perl bin2hex.pl banner.gif 0 >source.txt
Listing #1 : TEXT code. Download demo1.bat (0.17 KB).
 
You will end-up with a source.txt file with content similar to the following:
 
# begin binary data:
$bin_data = # 42
"x47x49x46x38x39x61x01".
"x00x01x00x80x00x00x00x00".
"x00xFFxFFxFFx21xF9x04".
"x01x00x00x00x00x2Cx00x00".
"x00x00x01x00x01x00x40".
"x02x01x44x00x3B";
# end binary data. size = 42 bytes
Listing #2 : TEXT code. Download result1.txt (0.27 KB).

comments