Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Why is there an ASCII mode in FTP, which is prevalent in today's software and FTP implementations? Why not just always use binary regardless of the data?

share|improve this question

migrated from stackoverflow.com Jul 16 '09 at 2:09

This question came from our site for professional and enthusiast programmers.

add comment

7 Answers 7

up vote 15 down vote accepted

When in doubt, read the RFC:

File-structure is the default to be assumed if the STRUcture command has not been used but both file and record structures must be accepted for "text" files (i.e., files with TYPE ASCII or EBCDIC) by all FTP implementations. The structure of a file will affect both the transfer mode of a file (see the Section on Transmission Modes) and the interpretation and storage of the file.

The "natural" structure of a file will depend on which host stores the file. A source-code file will usually be stored on an IBM Mainframe in fixed length records but on a DEC TOPS-20 as a stream of characters partitioned into lines, for example by . If the transfer of files between such disparate sites is to be useful, there must be some way for one site to recognize the other's assumptions about the file.

etc etc ... In short, it is to ensure that text representations in one encoding got converted properly when transferred to hosts using a different encoding.

share|improve this answer
add comment

Because different operating systems (Windows, UNIX, VAX) use different line ending methods for simple text files.

Windows (DOS) uses a CR/LF pair, UNIX uses only one of them. ASCII mode converts CRLF pairs and BIN mode doesn't.

Ron

share|improve this answer
2  
It's more than just the line ending encoding differences you mention, but it is also about the differences encoding of characters themselves such as the difference between ASCII and EBCDIC. The answer by @Sinan sites the specifics documented in RFC-959 –  Tall Jeff Jul 16 '09 at 2:22
add comment

I think it's just because it sometimes is convenient. Back in the day when FTP was how you got files from one system to the next, it was a big timesaver -- you didn't have to know what the system was on the other end in order to have a readable text file.

But yeah, mostly it's just a nuisance today. Just a corrupt-o-matic machine for the uninitiated!

share|improve this answer
add comment

ASCII mode is used so that the software can automatically change EOL characters to the proper values for the client/server depending on if you are uploading/downloading. If you are uploading to the same type of system as you are using, there is no difference in these modes.

The reason for this mode though is because not all software on all systems will correctly handle EOL's that aren't the exact proper type of EOL (for instance, alot of Windows software will only handle "\r\n" properly and will balk something horrible on "\n").

share|improve this answer
add comment

Some nice explanation here http://courses.wccnet.edu/computer/mod/na36c.htm

Please read the section 'ASCII and Binary in FTP'

cheers

share|improve this answer
add comment

The shortest answer is that this was (literally, I think it preceded telnet) the first app written for the ip protocol suite, and they had nothing to steal from.

:-D

But seriously, look at some things, like the way the data connection is set up, and that it runs on it's own port, but you cannot use the terminal session for anything (like, say, queuing up the next file).

share|improve this answer
add comment

The original reason was to decrease transmission sizes (and times) by 1/8 (since ASCII uses 7 bits, and binary uses all 8 bits). 20+ years ago this resulted in significant time savings over modem. Today, everything can just be sent binary, and the ascii mode is there for backwards-compatibility.

share|improve this answer
    
Either way it uses 8-bit transmission units. –  mark4o Aug 20 '09 at 18:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.