converting carriage return
- Posted by D & B Edmunds <dae at PACLINK.COM> Jun 15, 1997
- 696 views
Hello to group! I am trying to encrypt a file, using a simple xor routine on each byte in it. I find that carriage return-line feed is not converted correctly using getc(), and can't figure out a fast way to do this. -- my code procedure input() integer file_in integer file_out char char_in char char_out file_in = open("x.in", "r") --file must exist file_out = open("x.out","w") --output file --loop through x.in while 1 do char_in = getc(file_in) if char_in = -1 then exit --get out of the loop at end of file end if char_out = xor_bits(char_out, #10) -- write to file puts(file_out,char_out) end while close(file_in) close(file_out) puts(1,"DONE!") end procedure -- If I do a simple gets, puts the two files are the same, but if I try to convert each 'char', then the carriage return/line feed combination is not separated into two bytes, and is not written correctly (the x0D part (carriage return)) is lost. If you can help please email me at dae at paclink.com. Thanks.