Binary transfer type
As different platforms operating systems use different format of text files, many transfer protocols support special mode for transferring text files called text or ASCII mode.
In the mode the file is not only transferred, but also converted to binary transfer type used by the target platform. The mode must not binary transfer type used for binary files including document files from modern text processors, like Microsoft Wordas they must be transferred without modification.
It is set as one binary transfer type the transfer settings. WinSCP also has a special Automatic mode default. With this mode WinSCP decides automatically about transfer mode for a particular file based on its filename usually the file extension. The so-called binary transfer type file mask can be configured in dialogs mentioned above.
You can modify the mask as you need. Files not matching the mask are transferred using Binary mode. There are two options how to support text mode transfers. The first option is that the client WinSCP knows directly the text file format used by the server and converts the file to the format before transfer. The second option is that there is some in advance agreed canonical format to which the client converts the file before transfer and from which the server converts it if necessary after transfer to its own format.
It this case the client WinSCP must directly know and support the server-side format. Generally there are plenty of text file formats, almost every platform has it own format. You can select between them on Environment page of Advanced Site Settings dialog. WebDAV and S3 protocols do not allow selecting transfer mode. The transfer mode is set as part of transfer settings. Note that there are two predefined transfer settings presetsText and Binary binary transfer type may help you switching the mode.
To configure transfer mode in scriptinguse -transfer switch of file transfer commands. NET assembly use TransferOptions. WinSCP can perform additional modifications to the text files during transfer, if configured so. For that reason with SCP protocol, the whole file is converted in memory before the transfer.
If the file is too large binary transfer type common for text filesyou can run out of memory during conversion. So binary transfer type transfer large text file, either force binary mode if possible or switch to SFTP protocol.
See Why are text file line breaks wrong after the file is transferred or edited? Actually with FTPfile is uploaded unmodified, anticipating the server to be able to convert it to its own format.