Read an Hexa file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dany

    Read an Hexa file

    Hi
    When I open an Hexa file I have some weird char like when I open it with
    Notepad. I want to open it in a readeable form (ex: "FF25AB") like with
    Ultra edit.
    Thanks

    regards,
    Dany


  • Agent Mulder

    #2
    Re: Read an Hexa file

    Dany> Hi
    Dany> When I open an Hexa file I have some weird char like when I open it
    with
    Dany> Notepad. I want to open it in a readeable form (ex: "FF25AB") like
    with
    Dany> Ultra edit.

    Use Ultra edit to open your Hexa file


    Comment

    • Allan Bruce

      #3
      Re: Read an Hexa file


      "Dany" <dany_tambicann ou@yahoo.fr> wrote in message
      news:bf8ib4$88m $1@news-reader5.wanadoo .fr...[color=blue]
      > Hi
      > When I open an Hexa file I have some weird char like when I open it with
      > Notepad. I want to open it in a readeable form (ex: "FF25AB") like with
      > Ultra edit.
      > Thanks
      >
      > regards,
      > Dany
      >
      >[/color]

      If you want it to look like ultra-edit then you would have to ouptut the
      characters yourself with some kind of conversion to go from 255 to FF. What
      UltraEdit does is loads in the binary file and then does this conversion to
      (slightly more) human readable form. You will not get this in Notepad
      without the method I suggested above
      Allan


      Comment

      • Allan Bruce

        #4
        Re: Read an Hexa file


        "Dany" <dany_tambicann ou@yahoo.fr> wrote in message
        news:bf8r26$jah $1@news-reader4.wanadoo .fr...[color=blue]
        > Well I can't proceed to any convertion because I havn't number or letter[/color]
        to[color=blue]
        > work with. I only have some box, smiley and other weird character
        >
        >
        > "Allan Bruce" <abruce@TAKEAWA Ycsd.abdn.ac.uk > a écrit dans le message de
        > news:bf8iha$n5m $1@news.abdn.ac .uk...[color=green]
        > >
        > > "Dany" <dany_tambicann ou@yahoo.fr> wrote in message
        > > news:bf8ib4$88m $1@news-reader5.wanadoo .fr...[color=darkred]
        > > > Hi
        > > > When I open an Hexa file I have some weird char like when I open it[/color][/color][/color]
        with[color=blue][color=green][color=darkred]
        > > > Notepad. I want to open it in a readeable form (ex: "FF25AB") like[/color][/color][/color]
        with[color=blue][color=green][color=darkred]
        > > > Ultra edit.
        > > > Thanks
        > > >
        > > > regards,
        > > > Dany
        > > >
        > > >[/color]
        > >
        > > If you want it to look like ultra-edit then you would have to ouptut the
        > > characters yourself with some kind of conversion to go from 255 to FF.[/color]
        > What[color=green]
        > > UltraEdit does is loads in the binary file and then does this conversion[/color]
        > to[color=green]
        > > (slightly more) human readable form. You will not get this in Notepad
        > > without the method I suggested above
        > > Allan
        > >
        > >[/color]
        >
        >[/color]

        I dont understand, if you mean you have a file which is in this mode at the
        moment, then I suggest you read the file in a c++ program in binary mode.
        Perhaps storing the contents as an array of unsigned chars. Then carry out
        a conversion on each one.
        Each unsigned char will be 0-255 which if you divide by 16 will get the
        first hex digit (e.g. if it is 10 then the hex digit will be A).
        Now if you subtract the (first digit)*16 from the unsigned char, you will be
        left with the second digit. Now you can output this in a stream of hex
        characters just like ultra-edit
        Allan


        Comment

        • Thomas Matthews

          #5
          Re: Read an Hexa file

          Dany wrote:
          [color=blue]
          > Hi
          > When I open an Hexa file I have some weird char like when I open it with
          > Notepad. I want to open it in a readeable form (ex: "FF25AB") like with
          > Ultra edit.
          > Thanks
          >
          > regards,
          > Dany
          >
          >[/color]
          There is a tool in the Unix world, "od" or octal dump, which can
          display a binary file in human readable form.

          Many editors, such as XEmacs and Codewright, can display binary
          files in human readable form.

          Or you can write a utility which will read a file and output
          the human readable format:
          #include <fstream>
          using namespace std;

          int main(void)
          {
          ifstream inp_file("my_fi le.bin", ios_base::binar y);
          unsigned char byte;
          while (inp_file.get(b yte))
          {
          cout << hex << static_cast<uns igned short>(byte)
          << ' ';
          }
          cout << endl;
          return 0;
          }


          --
          Thomas Matthews

          C++ newsgroup welcome message:

          C++ Faq: http://www.parashift.com/c++-faq-lite
          C Faq: http://www.eskimo.com/~scs/c-faq/top.html
          alt.comp.lang.l earn.c-c++ faq:

          Other sites:
          http://www.josuttis.com -- C++ STL Library book

          Comment

          Working...