We came across a recent problem after downloading numerous files via FTP, our files have been converted so they contain double line spacing instead of the standard spacing that the programmer had put in.
After a bit of research we now understand that the reasoning behind this is because of Windows and UNIX file types. Windos, UNIX and MAC systems all have different ways of formatting line breaks. Windows/DOS use a pair of CR and LF characters as line breaks. UNIX uses LF only and MAC uses the CR character only. So with working on a Windows machine and uploaded the files via FTP we immediately come across this problem.
Many FTP clients can either transfer the file via ascii or binary. Ascii mode the FTP client will convert the line breaks, whereas in binary mode it will not. In ascii mode, transferring a file from a Windows machine to a Linux server will result in a UNIX file on the server. Downloading the file from the server will convert that file back to a Windows file. This will only work within ascii mode.
Using binary mode to do file transfers is what messes the line breaks up. Uploading a file from a Windows machine will show the file as having CR LF line breaks on the server. If that file is then downloaded from the server a conversion of UNIX to Windows will take place. However during this conversion it will replace each LF to CR LF, resulting in having CR CR LF as the line breaks.
Here is an example of what our code looked like before:
Then after we converted it:
To avoid this, simply don’t use binary mode unless you specifically need to.
If you’ve already come across this and now have a selection of files with double line breaks EditPad Pro will has a converter tool that will allow you to convert all double line breaks to single line breaks. To do this, you’ll need the Pro version, that you can download on a 30day trial here. Once installed load up your file that you need to convert and select Convert -> Double -> Single Spacing. Upload your file using Ascii (or auto) and you should have no more problems.