If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
MoonKid wrote:But isn't there a portable wx-way to set a newline?
No... That is beyond wx's control. notepad, notepad++ or any other editor is responsible for how they interpret and display a file. Some (mostly on windows) use \r\n to mean a new line, others (unix) use just \n. notepad++ I am not familiar with but the name makes me think it is for programmers and thus is probably smart enough to handle either.
But to sum up, wx can't control how another program chooses to interpret data. Wx will provide you a portable way to write that data to a file, but what some other program then does with the data is up to that program.
MoonKid wrote:We know that unix use '\n' and windows use '\r\n'. It doesn't matter how other applications interpret this.
Not true. That distinction is not dictated by the OS. It is determined by the programs that read and write text files. There is no hard and fast rule on an operating system as to what constitutes a "newline". It depends on the program, not the OS. I've got files that end in \r\n that open fine on Linux and files that end in \n that open file in Windows. There is "what the majority does" but that is not a must like / versus \.
Frank wrote:Just use the standard C++ streams instead of wxFile.
They take care of the linefeends, no need to do it yourself. Write "\n", the standardlib will convert it automatically to "\r\n" on windows.
Not sure that this fix's the OP original problem only changes it. Some small number of programs on windows(those expecting \n only) will show an extra line feed.
Furthermore, if the OP's program outputs \n on some systems and \r\n on others opening 2 files on created on windows and on OSX side by side will show two different results. Not sure if this is desireable. Most users expect that if an app is available on multiple platforms that the file created by that app should be consistant across all those platforms.
Imagine OpenOffice or MS Office creating different word files on unix and windows?