What's the point of ASCII mode in FTP?

17

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?

zildjohn01

Posted 2009-07-16T01:55:05.323

Reputation: 2 212

Answers

24

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.

Sinan Ünür

Posted 2009-07-16T01:55:05.323

Reputation: 991

When in doubt: search Google and find the answer on StackExchange. – ke4ukz – 2019-06-14T17:21:59.300

4

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

user14456

Posted 2009-07-16T01:55:05.323

Reputation: 141

4It'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 – 2009-07-16T02:22:12.120

1

ASCII mode had its place back in the day when character and EOL encoding was a real problem, but I would like to see ftp clients remove or perhaps just hide this option today. Nowdays it's mostly just EOL conventions that get messed up between systems, but I've found most decent text editors don't care anymore anyway. So in order to avoid corrupting binary files (or even some text based ones), I recommend just using binary mode for everything.

boomhauer

Posted 2009-07-16T01:55:05.323

Reputation: 115

1

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!

David Markle

Posted 2009-07-16T01:55:05.323

Reputation: 454

-1

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").

Matthew Scharley

Posted 2009-07-16T01:55:05.323

Reputation: 4 083

"there is no difference in these modes." - This is not true. Sending a binary file in ascii mode is likely to corrupt it. Badly. – Beefster – 2018-12-11T23:38:29.623