Read an Hexa file

Discussion in 'C++' started by Allan Bruce, Jul 18, 2003.

  1. Allan Bruce

    Allan Bruce Guest

    "Dany" <> wrote in message
    news:bf8ib4$88m$...
    > 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
    >
    >


    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
    Allan Bruce, Jul 18, 2003
    #1
    1. Advertising

  2. Allan Bruce

    Dany Guest

    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
    Dany, Jul 18, 2003
    #2
    1. Advertising

  3. Allan Bruce

    Agent Mulder Guest

    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
    Agent Mulder, Jul 18, 2003
    #3
  4. Allan Bruce

    Allan Bruce Guest

    "Dany" <> wrote in message
    news:bf8r26$jah$...
    > Well I can't proceed to any convertion because I havn't number or letter

    to
    > work with. I only have some box, smiley and other weird character
    >
    >
    > "Allan Bruce" <> a écrit dans le message de
    > news:bf8iha$n5m$...
    > >
    > > "Dany" <> wrote in message
    > > news:bf8ib4$88m$...
    > > > 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
    > > >
    > > >

    > >
    > > 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
    > >
    > >

    >
    >


    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
    Allan Bruce, Jul 18, 2003
    #4
  5. Dany wrote:

    > 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
    >
    >

    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_file.bin", ios_base::binary);
    unsigned char byte;
    while (inp_file.get(byte))
    {
    cout << hex << static_cast<unsigned short>(byte)
    << ' ';
    }
    cout << endl;
    return 0;
    }


    --
    Thomas Matthews

    C++ newsgroup welcome message:
    http://www.slack.net/~shiva/welcome.txt
    C++ Faq: http://www.parashift.com/c -faq-lite
    C Faq: http://www.eskimo.com/~scs/c-faq/top.html
    alt.comp.lang.learn.c-c++ faq:
    http://www.raos.demon.uk/acllc-c /faq.html
    Other sites:
    http://www.josuttis.com -- C++ STL Library book
    Thomas Matthews, Jul 18, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. PC
    Replies:
    2
    Views:
    3,947
    Marc Guardiani
    Nov 12, 2003
  2. miko

    convert euc-kr to hexa

    miko, Sep 21, 2003, in forum: Java
    Replies:
    1
    Views:
    442
    Roedy Green
    Sep 21, 2003
  3. Golan

    Converting hexa to decimal

    Golan, Jan 8, 2004, in forum: C Programming
    Replies:
    3
    Views:
    2,163
    Kevin Goodsell
    Jan 9, 2004
  4. Chandra

    Hexa reading from a file

    Chandra, Mar 1, 2007, in forum: C++
    Replies:
    1
    Views:
    295
    mlimber
    Mar 1, 2007
  5. Sarath
    Replies:
    4
    Views:
    3,998
    Joe Greer
    Jan 30, 2008
Loading...

Share This Page