My program read a Windows text file line by line, using fgets with MinGW.
Each line is ended by CR LF ('\r', '\n').
The text file is generated by tools and sometimes contains the character '\n' in the data.
I found out that fgets ignores every character after the '\n' and part of my data is missing.
How to change this behavior, so that:
- Single
'\n'are treated as a normal character '\r' '\n'is treated as new line
Edit:
I found out that some double-quoted strings in my file do have '\n' in the data, but also do have '\r' '\n' in the data somtimes. Unfortunately, I cannot fix the tools. So I had to write some code, as suggested in the valuable comments.