Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Read an Hexa file (http://www.velocityreviews.com/forums/t275776-read-an-hexa-file.html)

Allan Bruce 07-18-2003 10:30 AM

Re: Read an Hexa file
 

"Dany" <dany_tambicannou@yahoo.fr> wrote in message
news:bf8ib4$88m$1@news-reader5.wanadoo.fr...
> 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



Dany 07-18-2003 10:32 AM

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 07-18-2003 10:39 AM

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



Allan Bruce 07-18-2003 01:39 PM

Re: Read an Hexa file
 

"Dany" <dany_tambicannou@yahoo.fr> wrote in message
news:bf8r26$jah$1@news-reader4.wanadoo.fr...
> 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" <abruce@TAKEAWAYcsd.abdn.ac.uk> a écrit dans le message de
> news:bf8iha$n5m$1@news.abdn.ac.uk...
> >
> > "Dany" <dany_tambicannou@yahoo.fr> wrote in message
> > news:bf8ib4$88m$1@news-reader5.wanadoo.fr...
> > > 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



Thomas Matthews 07-18-2003 01:58 PM

Re: Read an Hexa file
 
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



All times are GMT. The time now is 05:01 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.