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

convert a binary file to ascii

Reply to Message Icon

Original Message
Name: jkps
Date: May 4, 2004 at 04:22:58 Pacific
Subject: convert a binary file to ascii
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 !!!!!!!!


Report Offensive Message For Removal

Response Number 1
Name: jaivrat
Date: June 3, 2004 at 20:36:33 Pacific
Subject: convert a binary file to ascii
Reply: (edit)

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


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: convert a binary file to ascii

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software