Logo Search packages:      
Sourcecode: qmf version File versions  Download package

void QMailCodec::decode ( QTextStream &  out,
QDataStream &  in,
const QString &  charset 
) [virtual, inherited]

Writes the data read from the stream in to the stream out, converting from a sequence of 7-bit ASCII characters. The characters read from in are decoded from the text encoding charset to unicode.

See also:

Definition at line 165 of file qmailcodec.cpp.

References QMailCodec::codecForName(), and QMailCodec::decodeChunk().

Referenced by QMailCodec::decode().

    if (QTextCodec* codec = codecForName(charset.toLatin1()))
        QByteArray decoded;
            QDataStream decodedStream(&decoded, QIODevice::WriteOnly);
            char* buffer = new char[MaxCharacters];
            while (!in.atEnd())
                int length = in.readRawData(buffer, MaxCharacters);

                // Allow for decoded data to be twice the size without reallocation
                decoded.reserve(decoded.size() + (MaxCharacters * 2));

                decodeChunk(decodedStream, buffer, length, in.atEnd());
            delete [] buffer;

        // This is an unfortunately-necessary copy operation; we should investigate
        // using QTextCodec::makeDecoder, and adding a factory method to 
        // QMailMessagePartContainer that returns a readable QIODevice*
        QString unicode = codec->toUnicode(decoded);
        out << unicode;

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index