Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions codeless banner

QMailBase64Codec Class Reference
[QtMessagingModule, QtPimModule]

The QMailBase64Codec class encodes or decodes between 8-bit data and 7-bit ASCII, using the Base64 character mapping scheme. More...

    #include <QMailBase64Codec>

This class is under development and is subject to change.

Inherits QMailCodec.

Public Types

Public Functions

Additional Inherited Members


Detailed Description

The QMailBase64Codec class encodes or decodes between 8-bit data and 7-bit ASCII, using the Base64 character mapping scheme.

The Base64 character mapping scheme maps arbitrary 8-bit values into a range of 64 printable characters from the 7-bit ASCII set. The mapping scheme used is defined in RFC 2045 (Multipurpose Internet Mail Extensions Part One). This encoding is also defined as the '"B" encoding' for 'encoded words' in RFC 2047 (Multipurpose Internet Mail Extensions Part Three).

The Base64 scheme encodes every incoming octet regardless of its original value, and thus produces the same ratio of output length to input length for any input data sequence. Since Base64 encodes four output characters for every three input octets, it produces a 33% increase in stream size when encoding.

An instance of QMailBase64Codec contains state information about the encoding or decoding operation it performs, so an instance should be used for a single coding operation only:

    QString textData = acquireInput();

    // Encode the string data to a UTF-8 byte sequence, and then encode to Base64
    QMailBase64Codec encoder;
    QByteArray base64Data = encoder.encode(textData, "UTF-8");

See also QMailCodec.


Member Type Documentation

enum QMailBase64Codec::ContentType

This enumerated type is used to specify whether content is textual data or binary data.

ConstantValueDescription
QMailBase64Codec::Text0The data is textual data; newline sequences within the data will be converted during coding.
QMailBase64Codec::Binary1The data is not textual, and does not contain newline sequences.


Member Function Documentation

QMailBase64Codec::QMailBase64Codec ( ContentType content, int maximumLineLength = -1 )

Constructs a codec object for coding to or from Base64 encoding.

If content is QMailBase64Codec::Text, then newline sequences will be converted between the local representation (for example, 0x0A on Unix) and the transmission standard representation (0x0D 0x0A). Otherwise, the data will be coded without modification.

The maximum number of encoded characters per output line can be specified as maximumLineLength. If not specified, or specified to a non-positive value, a default value will be used.


Copyright © 2009 Nokia Trademarks
Qt Extended 4.4.3