| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
FTP Data Representation: Data Types, Data Structures and Format Control (Page 2 of 3) ASCII Data Type Line Delimiting Issues When the ASCII data type is used, differences in internal representations between systems are handled by using a universal external representation that acts as a common language. Lines of the file being transmitted are converted by the sending FTP process from the sender's internal representation to the neutral ASCII representation used by the Telnet protocol (NETASCII) with each line ending in CR+LF. The receiving device then converts from this neutral representation to the internal format used by the recipient file system. For example, when using FTP to move a text file from a Macintosh to a UNIX system, each line would have the CR changed to a CR+LF for transmission over the FTP data channel. The receiving UNIX system would change each CR+LF to just LF, so UNIX programs would read it properly. Note that this actually does mean the resulting file can be bigger or smaller than the original, if it is transferred between systems using ASCII mode. Also, since FTP works by converting to a neutral representation for universality, sending an ASCII file from a UNIX system to a UNIX system means each LF is changed to CR+LF for transmission, then changed back to just LF by the recipient. Slightly inefficient, but not that big a deal. It's very important that when FTP is used, the correct data type be specified with the appropriate user command. Sending a text file between dissimilar systems without setting ASCII mode will result in either a file that cannot be properly read on the destination, or one that has stray characters in it. Conversely, binary files must be sent in binary mode. If you send something like a ZIP file or a JPG graphic in ASCII mode, the FTP software will think it is a text file. It will treat the file as if it were text, and each time it encounters bytes in the file that look like CR, LF or CR+LF it will convert them, which you do not want. (Having the wrong data type set is a leading cause of corrupted files when using FTP to move files between PCs and UNIX systems. I know from experience!)
Home - Table Of Contents - Contact Us The TCP/IP Guide (http://www.TCPIPGuide.com) Version 3.0 - Version Date: September 20, 2005 © Copyright 2001-2005 Charles M. Kozierok. All Rights Reserved. Not responsible for any loss resulting from the use of this site. |