Computing.Net > Forums > Unix > convert a binary file to ascii

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

convert a binary file to ascii

Reply to Message Icon

Name: jkps
Date: May 4, 2004 at 04:22:58 Pacific
OS: windows XP
CPU/Ram: Solaris
Comment:

Hi all,
I was editing my c++ file in sun-solaris and then when i ran the make file i got an error saying some junk char not defined in the file,later when i opened i found my C++ file that iw as eidting was full of junks,i guess it wud have been changed to a binary file?

Can anybody helpo me out in converting the file to ascii format??
This is very urgent !!!!!!!!



Sponsored Link
Ads by Google

Response Number 1
Name: jaivrat
Date: June 3, 2004 at 20:36:33 Pacific
Reply:

Hi,

This reply is two days late. I do not know if it is usefull now. but still:

First thing to do:
You can see what junk charactres have invaded your file by giving command

$ cat -v youfilename.cpp > exposed.cpp

then you can see in the exposed.cpp by vi editor or anything to see the junk characters . If there are only a few then you can delete them

But if they are so many then you have to wite a c program which reads file charcter by character and writes it to another file ONLY IF that character is a PRINTABLE character.

You check whether the character is printable using a C library function defined in /usr/include/ctype.h

and the function is

int isprint(int ch);

Hope this works.

Jai Vrat Singh


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: convert a binary file to ascii

binary to ASCII www.computing.net/answers/unix/binary-to-ascii/5502.html

converting flat files to tables in unix www.computing.net/answers/unix/converting-flat-files-to-tables-in-unix/1553.html

Piping a binary file ONLINE? www.computing.net/answers/unix/piping-a-binary-file-online/5465.html