[Qt-interest] Howto get default carriage return ?

Thiago Macieira thiago at kde.org
Fri Oct 22 17:54:54 CEST 2010


Em Sexta-feira 22 Outubro 2010, às 16:03:54, Aaron Lewis escreveu:
> Hmm , if i could simply use "\n" as line terminators ..
> 
> We've fall backed to the elementary question , i'm just trying to find a
> suitable one , maybe i should dive into Kate's source code , see how it
> detects default file format ...
> 
> Or just take an assumption that those files are created on the platform
> that my app is running , not moved from other platforms , that's why i'm
> looking for a elegant solutions , should Qt supply such functions like
> QDir::separator() , which provides "/" or "\" depends on target platforms ?
> 
> Thanks !

Ever since the dawn of time, line termination is "\n" in C and C++.

The file streams and devices translate the \n to the appropriate line 
termination sequence on the platform. That's LF on Unix (matching the '\n'), 
CRLF on DOS and Windows, CR only on Mac OS 9.

So you should always use \n and open your file streams in text mode (the "t" 
option to fopen or QIODevice::Text to QIODevice::open).

If you're writing an application that deals with text files from other 
platforms, treat all files as binary and detect the three possibilities.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101022/312199c3/attachment.bin 


More information about the Qt-interest-old mailing list