Just as a sample, I want to load a text file into a TextEditor component and save the text afterwards in the same or a different file.
The code sequence is:
String text = chosenFile.loadFileAsString();
textEditor->setText (text)
…
String text = textEditor->getText();
chosenFile.replaceWithText (text);
Unfortunatly this code sequence replaces “\r\n” sequences in the text file with single “\r” characters, which corrupts the text file in Windows.
As far as I have debugged the code, when using “setText” with “\r\n” sequences, these are inserted into the TextEditor as atoms with the single character “\r”, whereas newlines entered in the editor are represented as “\n” atoms. When writing the text into the file, “\n” is written as “\r\n”, whereas a single “\r” is written as it is.
Am I right? Can that be fixed or do I have to code a workaround?
Thank You,
Andreas