TextFormat
The TextFormat
class provides functionality to load and save text files in various file formats.
It supports UTF-8, UTF-16, optional byte order marks
(BOM), and either Unix or Windows-style newlines.
All text loaded through TextFormat
is converted to UTF-8 with Unix-style newlines and no byte
order mark (BOM).
For more information, see Unicode Support.
Header File
#include <ply-runtime/io/text/TextFormat.h>
Data Members
-
Possible values are
Bytes
,UTF8
,UTF16_be
andUTF16_le
. -
Possible values are
LF
andCRLF
. -
Whether the text begins with a byte order mark (BOM).
Member Functions
-
Returns a
TextFormat
withUTF8
,LF
and no BOM. -
Returns a default
TextFormat
according to the host platform. On Windows, the default isUTF8
,CRLF
and no BOM. On Linux and macOS, the default isUTF8
,LF
and no BOM. -
Attempts to guess the text file format of the contents of
ins
. This function reads up to 4 KB of data fromins
, then rewinds it back to the beginning usingInStream::rewind()
. -
Creates a new
InStream
that converts the raw contents ofins
to UTF-8 with Unix-style newlines and no byte order mark (BOM). The contents ofins
are expected to have the format described by the providedTextFormat
object. Conversion is performed on-the-fly while data is being read.[FIXME: Say something here about OptionallyOwned.]
-
Creates a new
OutStream
that writes raw data toouts
in the format described by the providedTextFormat
object. The resultingOutStream
object expects UTF-8-encoded text. TheOutStream
accepts both Windows and Unix-style newlines; all newlines will be converted to the format described by the providedTextFormat
object. Conversion is performed on-the-fly while data is written. bool TextFormat::operator==(const TextFormat& other) const
[code]-
Returns
true
if theTextFormat
s are identical.