Why do I get different EOL for different files? - windows-xp

What can cause Notepad++ to make new lines as CRLF in one file and only LF in the other?
Both files were created at the same folder from the same OS and no modifications to Notepad++ preferences were made, AFAIK... Is there any option in Notepad++ that changes how new lines are defined?

Go to Edit->EOL Conversion -- change setting to Windows Format or Unix Format or Old Mac Format (depending on your prefernces)

Related

Problem with text editors in macOS for Diff of two files with ANSI escape codes?

I have two log files in macOS where colors are defined by ANSI Escape codes and want to compare them. Having ANSI escape codes in plain text makes it really annoying to read the diff. I am looking for either (i) removing the ANSI escape codes from files, or (ii) bringing back the colour highlighting to the log files. Any recommendations?
I tried some text edirors in Mac but no success:
Sublime text. Installed ANSIescape using 'Sublime Package Control'. It's nice for displaying ANSI code with color for a single file, but it does not work for comparing two files. Because the diff are displayed in two separate files, not side-by-side.
Visual studio code. It has nice side-by-side comparison by the command code --diff file1 file2, but I failed to find any ANSI escape codes plugins for VS code.
Vim. I failed to install the plugin based on AnsiEsc.vim.
Once I had installed it in other system, but the problem was when you open the vim editor every time you need to type :AnsiEsc, as discussed here. The error I get in installing the plugin is:
*vimball*** (vimball#Decompress) gunzip may have failed with <~/AnsiEsc.vba.gz>
Press <cr> to continue
***vimball*** Source this file to extract it! (:so %)
Error detected while processing SourceCmd Auto commands for "*.vba.gz":
E484: Can't open file ~/AnsiEsc.vba

VSCode not defaulting to \n end of line

Generally me and my developers prefer UNIX line endings. I have updated the setting in VSCode for end of line settings to the following...
"files.eol": "\n"
This seems to work when creating new files, however any pre-existing file from our source code is defaulted to CRLF. Is there any way that I can set our end of lines to \n across all files, even pre-existing files from our repo's source code?
When VSCode opens a file, if the file has at least one line terminator in it, its per-file EOL value will be set according to whatever is the most common line terminator in the file, regardless of files.eol. That means that if files are opening as CRLF, then those files are already CRLF on disk.
My guess is your SCM is checking them out with CRLF endings and you probably can adjust its configuration so it checks them out as LF instead.

Can SAP detect encoding and line endings?

How to read ASCII files with mixed line endings (Windows and Unix) and UTF-16 Big Endian files in SAP?
Background: our ABAP application must read some of our configuration files. Most of them are ASCII files (normal text files) and one is Unicode Big Endian. So far, the files were read using ASCII mode and things were fine during our test.
However, the following happened at customers: the configuration files are located on a Linux terminal, so it has Unix Line Endings. People read the configuration files via FTP or similar and transport it to the Windows machine. On the Windows machine, they adapt some of the settings. Depending on the editor, our customers now have mixed line endings.
Those mixed line ending cause trouble when reading the file in ASCII mode in ABAP. The file is read up to the point where the line endings change plus a bit more but not the whole file.
I suggested reading the file in BINARY mode, remove all the CRs, then replace all the remaining LFs by CR LF. That worked fine - except for the UTF-16 BE file for which this approach results in a mess. So the whole thing was reverted.
I'm not an ABAP developer, I just have to test this. With my background in other programming languages I must assume there is a solution and I tend to decline a "CAN'T FIX" resolution of this bug.
you can use CL_ABAP_FILE_UTILITIES=>CHECK_FOR_BOMto determine which encoding the file has and then use the constants of class CL_ABAP_CHAR_UTILITIES to process further.

How to load a matlab file (.mat) in windows if it was originally saved in UNIX

I'm trying to open a .mat file in the windows environment but it is failing. It was created in a Unix environment. Also note that this file was first put in a .tar file first, ftp via binary method. The file opens in Unix and I don't think it was corrupted in any way.
The *.mat file format is platform agnostic. The OS does not matter.
There are a number of variants of the *.mat file which have been used, and older versions cannot always read formats saved with newer versions. You can save to an older version using flags available in the save command. These formats have been updated as the Matlab feature set has demanded a more flexible file format, and as other technologies have advanced, most notably HDF5 in the recent version.
Finally, the save command supports an ASCII formatted option. I suspect this is your current problem, based on your comment regarding the error message received.
To address your current problem:
First, check to see if the file is an ASCII file. The easiest way is to simply open it in notepat, wordpad, or even the matlab editor. If the file is text, then this becomes a file parsing problem, and the appropriate use of fscanf shoudl fix the problem.
If the file is actually a binary *.mat file then you probably have a Matlab version incompatability. Yuo can either go back to the source unix environment and save to an older version (eg save .... -v7) or update the Matlab version of the reading computer.

Emacs, hex editor and determing that a text file is in DOS format

Here's the simplified version of my problem: I have two text files, different data but identical first line and generated by the same program, although possibly on different OS's. When emacs reads one of them it says it is in DOS format, while it does not when reading the other.
I used several Hex editors (Bless, GHex, OKTeta on Kubuntu) and on all of them I see the same thing, which is that every line ends with the sequence OD OA (CR LF) for both files, including the last line.
So my question is: how does emacs determine what is a DOS file and what is not, and is there something else in the file the the Hex editor would not show, or add?
Both files have the same name, in different directories. Also I came upon this problem because I have C++ code that parses strings and failed on the file that emacs lists as DOS, so the issue is really with the file content.
Last note: you will notice there is no C/C++ tag. I'm not looking for advice on how to modify my C++ code to handle the situation. I know how to do it.
Thanks for your help
a
Emacs handles DOS files by converting the CRLF to LF when reading the file and then the LF back into CRLF when writing it out. So if there is a lone LF in the file, reading&writing would end up adding a CR even if the buffer had not been modified. For this reason, if there is such a lone LF hidden in the middle of the file, Emacs will handle the file not as DOS but as a UNIX file.