|  | Home |

# QMailQuotedPrintableCodec Class Reference

The QMailQuotedPrintableCodec class encodes or decodes between 8-bit data and 7-bit ASCII, using the 'quoted printable' character mapping scheme. More...

        #include <QMailQuotedPrintableCodec>

This class is under development and is subject to change.

Inherits QMailCodec.

- List of all members, including inherited members

## Public Types

enum | ConformanceType { Rfc2045, Rfc2047 }
enum | ContentType { Text, Binary }

## Public Functions

| QMailQuotedPrintableCodec ( ContentType content, ConformanceType conformance, int maximumLineLength = -1 )

## Reimplemented Public Functions

virtual QString | name () const

- 9 public functions inherited from QMailCodec

### Additional Inherited Members

- 3 static public members inherited from QMailCodec
- 2 protected functions inherited from QMailCodec

## Detailed Description

The QMailQuotedPrintableCodec class encodes or decodes between 8-bit data and 7-bit ASCII, using the 'quoted printable' character mapping scheme.

The 'quoted printable' character mapping scheme maps arbitrary 8-bit values into 7-bit ASCII characters, by replacing values that cannot be directly represented with an escape sequence. The mapping scheme used is defined in RFC 2045 (Multipurpose Internet Mail Extensions Part One). A minor variation on the scheme is defined as the '"Q" encoding' for 'encoded words' in RFC 2047 (Multipurpose Internet Mail Extensions Part Three).

The 'quoted printable' scheme encodes only those incoming octet values that cannot be directly represented in ASCII, by replacing the input octet with a three-character sequence that encodes the numeric value of the original octet. Therefore, the ratio of input length to output length for any input data sequence depends on the percentage of the input that corresponds to ASCII values, with ASCII-like encodings producing only small increases. With an input data encoding such as Latin-1 (ISO-8859-1), the output maintains a reasonable degree of human-readability.

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

        QByteArray asciiData = acquireInput();

        // We know the data is text in Latin-1 encoding, so decode the data from
        // quoted printable ASCII encoding, and then decode from Latin-1 to unicode
        QMailQuotedPrintableCodec decoder(QMailQuotedPrintableCodec::Text, QMailQuotedPrintableCodec::Rfc2045);
        QString textData = decoder.decode(asciiData, "ISO-8859-1");

See also QMailCodec.

## Member Type Documentation

### enum QMailQuotedPrintableCodec::ConformanceType

This enumerated type is used to specify which RFC the coding operation should conform to.

Constant | Value | Description
--- | --- | ---
`QMailQuotedPrintableCodec::Rfc2045` | `0` | The coding should be performed according to the requirements of RFC 2045.
`QMailQuotedPrintableCodec::Rfc2047` | `1` | The coding should be performed according to the requirements of RFC 2047's '"Q" encoding'.

### enum QMailQuotedPrintableCodec::ContentType

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

Constant | Value | Description
--- | --- | ---
`QMailQuotedPrintableCodec::Text` | `0` | The data is textual data; newline sequences within the data will be converted during coding.
`QMailQuotedPrintableCodec::Binary` | `1` | The data is not textual, and does not contain newline sequences.

## Member Function Documentation

### QMailQuotedPrintableCodec::QMailQuotedPrintableCodec ( ContentType content, ConformanceType conformance, int maximumLineLength = -1 )

Constructs a codec object for coding data of type content, using the mapping scheme specified by the requirements of conformance.

If content is QMailQuotedPrintableCodec::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.

If conformance is QMailQuotedPrintableCodec::Rfc2047, then coding will use the mapping scheme of the RFC 2047 '"Q" encoding'; otherwise the scheme defined in RFC 2045 will be used.

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

### QString QMailQuotedPrintableCodec::name () const `[virtual]`

Reimplemented from QMailCodec::name().