Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ascii clean function

Status
Not open for further replies.

ielo

Programmer
Jan 22, 2004
15
0
0
CA
Hi to all,

I noticed that ascii input files to a Linux C program I share with colleagues (we're in research, not professional programming) weren't being properly scanned. After a few days of debugging, we came to the conclusion that this had to do with semi-invisible characters, likely being inserted in the ascii files when going through their Windows-based mail server. This causes mismatches when trying to do string comparisons.

What is the easiest way to 'clean' ascii files? ... instead of using standalone apps, are there any open-source C functions out there that can do the trick? Integrated C functions would be preferable, as we can move between platforms ... Obvioulsy, we can take the time to improvize our own, but 'safer' code would be nice ... even helpful advice. Thnx.
 
The only semi-invisible (?!;) character in ASCII plain text files from Windows is '\r'. Windows line separator sequence is "\r\n" but *nix is '\n' only.
You may open Windows file in binary mode then copy it onto Linux without '\r'. It's so simple C program (read char by char , test every char and skip '\r' but copy others)...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top