Differences
This shows you the differences between the selected revisions of the page.
faq_line_breaks 2015-02-17 | faq_line_breaks 2023-10-06 (current) | ||
Line 1: | Line 1: | ||
- | ====== Why are text file line breaks wrong after the file is transferred or edited? ====== | + | ====== Why are text file line breaks wrong, after the file is transferred or edited? ====== |
After transferring or editing a file, it may happen that line breaks are wrong, what may manifest as: | After transferring or editing a file, it may happen that line breaks are wrong, what may manifest as: | ||
Line 12: | Line 12: | ||
Different platforms (operating systems) use a different format of text files. The most common formats are Unix and Windows format. A primary difference is that different character or sequence of characters is used to signify an end of a line. On Unix, it's LF character (''\n'', ''0A'' or 10 in decimal). On Windows, it's a sequence of two characters, CR and LF (''\r'' + ''\n'', ''0D'' + ''0A'' or 13 + 10 in decimal). | Different platforms (operating systems) use a different format of text files. The most common formats are Unix and Windows format. A primary difference is that different character or sequence of characters is used to signify an end of a line. On Unix, it's LF character (''\n'', ''0A'' or 10 in decimal). On Windows, it's a sequence of two characters, CR and LF (''\r'' + ''\n'', ''0D'' + ''0A'' or 13 + 10 in decimal). | ||
- | While many applications and systems nowadays can work with both formats, some require a specific format. When presenting a file in an another format, they fail to display it correctly, as described above. | + | While many applications and systems nowadays can work with both formats, some require a specific format (notably Windows Notepad supported Windows format only until Windows 10 1809). &win10 When presenting a file in another format, they fail to display it correctly, as described above. |
===== Text/ASCII Transfer Mode ===== | ===== Text/ASCII Transfer Mode ===== | ||
Line 18: | Line 18: | ||
For this reason, file transfer clients and servers support a text/ASCII [[transfer_mode|transfer mode]]. When transferring a file in this mode, the file gets (ideally) converted from a format native to a source system, to a format native to a target system. For example, when uploading a text file using text mode from Windows to Unix system, the file line endings get converted from CR+LF to LF. Opposite to the text/%%ASCII%% transfer mode is a binary transfer mode that transfer the file as is (binary identical). | For this reason, file transfer clients and servers support a text/ASCII [[transfer_mode|transfer mode]]. When transferring a file in this mode, the file gets (ideally) converted from a format native to a source system, to a format native to a target system. For example, when uploading a text file using text mode from Windows to Unix system, the file line endings get converted from CR+LF to LF. Opposite to the text/%%ASCII%% transfer mode is a binary transfer mode that transfer the file as is (binary identical). | ||
- | WinSCP by default uses the binary transfer mode for all regular file transfers. Learn how to configure it to [[transfer_mode#changing_transfer_mode|use the text/ASCII transfer mode]]. You may also need to configure [[ui_login_environment|correct server-side text file format]]. | + | WinSCP by default uses the binary transfer mode for all //regular file transfers//. Learn how to configure it to [[transfer_mode#changing|use the text/ASCII transfer mode]]. You may also need to configure [[ui_login_environment|correct server-side text file format]]. |
- | On the contrary, when you want to force WinSCP to use the binary mode, even when editing files in a text editor, you have to use an external text editor ((WinSCP internal editor does not support Unix file format.)) and configure WinSCP [[ui_editor_preferences#external|not to force text mode for edited files]]. Also make sure your external text editor saves the file in the format you need. ((Most text editors nowadays support different text file formats, not just a format native to the platform the editor runs on.)) | + | On the contrary, WinSCP always uses text transfer mode, when //editing file// in WinSCP internal editor (or Windows Notepad on Windows versions older then Windows 10 1809). If you want to force WinSCP to use the binary mode when editing files, you have to use an external text editor ((WinSCP internal editor does not support Unix file format.)) and make sure WinSCP [[ui_editor_preferences#external|does not force text mode for edited files]]. Also make sure your external text editor saves the file in the format you need. ((Most text editors nowadays support different text file formats, not just a format native to the platform the editor runs on.)) |
- | ===== Known Issues with Transfer Mode ===== | + | ===== [[known_issues]] Known Issues with Transfer Mode ===== |
- | * Pure-FTPd FTP server: When downloading a file with Windows line-endings (CR+LF) in a text/%%ASCII%% mode, the server replaces LF with CR+LF, resulting in an incorrect CR+CR+LF. When opening such file in an Internal editor of WinSCP, the editor interprets the sequence as two line endings (CR and CR+LF) resulting in a blank line after each and every content line. When the file is saved, the internal editor saves two Windows line endings CR+LF and CR+LF. On upload they get converted to two LF's. A workaround is to use an external editor and configure WinSCP [[ui_editor_preferences#external|not to force text mode for edited files]]. | + | * Pure-FTPd FTP server: When downloading a file with Windows line-endings (CR+LF) in a text/%%ASCII%% mode, the server replaces LF with CR+LF, resulting in an incorrect CR+CR+LF. When opening such file in an Internal editor of WinSCP, the editor interprets the sequence as two line endings (CR and CR+LF) resulting in a blank line after each and every content line. When the file is saved, the internal editor saves two Windows line endings CR+LF and CR+LF. On upload they get converted to two LF's. A workaround is to use an external editor and make sure WinSCP [[ui_editor_preferences#external|does not force text mode for edited files]]. |
- | ===== Debugging Text File Conversion ===== | + | ===== [[debugging]] Debugging Text File Conversion ===== |
If enabling (or disabling) text/ASCII transfer mode does not help with the problem and your transferred/edited file is still perceived incorrectly by the target system, you need to find out in what step the file got converted incorrectly (or haven't got converted). | If enabling (or disabling) text/ASCII transfer mode does not help with the problem and your transferred/edited file is still perceived incorrectly by the target system, you need to find out in what step the file got converted incorrectly (or haven't got converted). |