0

Using the QT library, is there a simple way to obtain the line ending characters particular to the platform where the program is being executed?

How can I obtain the line ending characters as a QString?

UndeadKernel
  • 515
  • 4
  • 15

1 Answers1

0

If you are working with text files, open files in text mode and use \n. Please note that using endl is no more portable than \n.

Community
  • 1
  • 1
Ho1
  • 1,239
  • 1
  • 11
  • 29
  • In addition, you need to set `QIODevice::Text` as an additional flag when opening the file, so that `\n` is properly translated to the platform-specific line ending. – coyotte508 Oct 14 '15 at 13:11
  • When working with text files QT takes care of the end line characters for you. But what about getting the end line characters in a QString to further do something with these? – UndeadKernel Oct 14 '15 at 13:18
  • @UndeadKernel It becomes important when you're reading or writing the string into files. If you use `\n` and text mode for your file operations, that would be fine. – Ho1 Oct 14 '15 at 13:29