I'm writing a program on a Linux platform that is generating text files that will be viewed on, inevitably, a Windows platform.
Right now, passing std::endl into a ostream generates the CR character only for newlines. Naturally, these text files look wrong in MS Notepad.
- Is there a way to change
std::endlsuch that it uses CR+LF for newline instead of LF? - I know I could write my own custom manipulator, like
win_endl, for generating my own newlines, but I use thestd::endlsymbol in a lot of places, and like many programmers, have a tendency to do the thing that requires the least work possible. Could I simply overloadstd::endlto produce CR+LF, or is this a dumb idea for maintainability?
NB: I checked out this question, but it's asking about going the other way, and the accepted answer seems rather incomplete.