File format conversion - HEX/Decimal into Bin

Discussion in 'Programmer's Corner' started by eblc1388, Aug 31, 2010.

  1. eblc1388

    Thread Starter Senior Member

    Nov 28, 2008
    1,542
    102
    Does anyone know of an utility to convert a simple text file (with hex or decimal representation, delimited by space or comma) into the binary equivalent?

    Most of my search in Google using "HEX to binary" turns up conversion programs which gives me conversion to "00110010" which is not what I wanted.

    [​IMG]
     
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
  3. eblc1388

    Thread Starter Senior Member

    Nov 28, 2008
    1,542
    102
    Thanks t06afre.

    I have used several hex editors in the past and none of them does that.

    I don't want an hex editor, as it will simply load the text file up for edit as if it is a binary file. I've attached the file if anyone would care to try.

    By the way, the Hackman's calculator in your link isn't free and its size of 20MB download so I would give it a miss unless I'm 100% sure that it can actually does what I wanted.
     
    • xxx.txt
      File size:
      1.6 KB
      Views:
      21
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    I am not sure what you want to do. In this editor you can type in both ASCII char (to the right), or bytes in form of hex number to the left. Both sides will be updated then you type in info
    The dwnload is 9.7 Mbyte not 20 ;)
     
  5. eblc1388

    Thread Starter Senior Member

    Nov 28, 2008
    1,542
    102
    Type it in manually? :confused:

    Now I understand why you have said most HEX editor does that.

    I was hoping there are some command line utility that let me do the conversion without typing.
     
  6. DonQ

    Active Member

    May 6, 2009
    320
    11
    I think when (old) DOS debug loads a file with a ".hex" extention, it converts it to binary when it loads it to memory. It then converts it back to hex and ascii to display the values on the screen. (It may need to be in 'intel.hex' form, or something similar. That would be an easy edit.)

    If you load it into debug, and then save it with a ".bin" extension, using debug commands, I think that will get what you want. Debug commands would be under help for that program, or available online.

    Although finding a utility to do this same thing should be easy, I don't know of a particular one by name. If I need it, I would just write a short program to fscanf(...), then fputc(), or something similar.
     
    Last edited: Aug 31, 2010
  7. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Lol I think I did this as a lab assignment in C programming many years ago. It should be easy to make a console program in windows or linux doing this. To day I only use Labview so I can not help. As long as you do not use Labview your self
     
  8. DonQ

    Active Member

    May 6, 2009
    320
    11
    A lab assignment?!:eek: Really?

    There's about 48 seconds of your life you'll never get back :D
     
  9. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Now now no need to be cocky:rolleyes:. This was one of the first assignments in a programming introduction class. Everybody has to start from zero at some point.
     
Loading...