There is no guaranteed way to repair the files because of the nature of the way ASCII mode works compared to Binary mode.
FTP ASCII mode is designed to convert line endings to the appropriate type between the source and destination operating systems. The most common conversion that is done here is
(0x0a
) becomes
(0x0d0a
) and vice versa, when transferring between *nix and Windows.
Lets say that we are transferring some images from a Linux server to a Windows machine, and we accidentally use ASCII mode. The FTP client is looking out for any
sequences in the incoming data and converting them to
in the data it saves to disk. This means that anywhere in the binary data there is a 0x0a
it becomes 0x0d0a
in the new data. But it won't convert an existing
to
- this will be left intact. No problem, you might think, I'll just convert all the 0x0d0a
back to 0x0a
and the file will be repaired. But wait... if the existing
sequences weren't converted, then they will be converted the wrong way in this new conversion pass.
The long of the short of it is you data is irrevocably corrupted. The only 100% guaranteed way to get the correct data back is to copy them off the server again, in binary mode.