Article Title: differences between ftp binary and ascii transmission methods. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
FTP can transmit files in multiple formats, usually determined by the system. Most systems (including UNIX systems) have only two modes: text mode and binary mode. The text transmitter uses ASCII characters separated by the carriage return key and line break, while binary can be transferred without conversion or formatting. The binary mode is faster than the text mode and can transmit all ASCII values, therefore, the system administrator generally sets FTP to binary mode.
In general, if you use the wrong mode to transmit your image, you will not be able to see the image and will see garbled characters. If you upload a CGI script in Error mode, you will not be able to run your script and you will see an Error message similar to Server 500 Error.
Therefore, you must use the correct mode. Images and execution files must be in BINARY mode. CGI scripts and common HTML files must be uploaded in ASCII mode.
Differences between ASCII and BINARY modes:
Files written in HTML and text must be uploaded in ASCII mode. files uploaded in BINARY mode may be damaged, resulting in file execution errors.
BINARY mode is used to transfer executable files, compressed files, and image files.
If you use ASCII mode, a bunch of garbled characters are displayed. You must use BINARY mode again.
In the second case, many ftp servers and client software can automatically identify file types and adopt corresponding transmission methods.
Ftp is an application layer protocol and has nothing to do with the specific operating system.
The difference between the ASCII mode and the BINARY mode is that the carriage return line breaks, while the binary mode does not process any data. The asci mode converts the carriage return line breaks to the carriage return characters of the local machine, for example, \ n under Unix, \ r \ n in Windows and \ r in Mac
Files are converted in ascii mode.
It cannot be said that different systems have different line breaks for carriage return.
Different systems have different row Terminators.
The unix system downstream Terminator is a byte, that is, the hexadecimal 0A.
The ms system has two bytes, namely, the hexadecimal 0D0A.
Therefore, when you download files (whether binary or text files) from the unix ftp server in ascii mode
If the byte is 0A, A 0D will be automatically inserted. Therefore, if your file is a binary file, such as an executable file or a compressed package
It cannot be used. If your file is a unix text file, you are correct in ascii mode. If binary mode is misused,
On windows, you can see that there is no line break in this file, which contains black boxes.
In general, we 'd better use the binary method to avoid errors. If there is a text format conversion problem, that is, the unix format
There are many tools to convert between the text in dos format and the text in dos format. Do not take risks during ftp transmission.
These things are not very clear.
MIME can be used to convert all characters to 0 ~ It is a string of 2 to 128 characters and then transmitted. After receiving, the receiver converts the received character MIME in reverse order. We usually use this character conversion method to send emails.
------------------------------------------------------------------
Supplement: You can see the differences between the two by using the cat-A file name in linux, of course, the premise is that the text uploaded in windows is in dos format, which can be viewed in advanced text editors such as ultraedit. The difference between the two is that the text uploaded in binary mode has one more ^ M symbol than the text mode, which is the/r carriage return symbol in dos format in windows, that is, the hexadecimal 0D mentioned above, and use global replacement in vi: % s/^ M // g [^ M use Ctrl + V + M instead of entering ^ M] to remove all carriage returns or use dos2unix file for conversion, in this way, the files saved or generated are the same as those uploaded in text mode...
Original address http://blog.88743.com/article/DailyBlog/291.htm