QStringDecoder Class
The QStringDecoder class decodes bytes into a QString. More…
| Header | #include <QStringDecoder> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
| Since | 6.0 |
| Inherits | QStringConverter |
List of all members, including inherited members
Public Functions
| QStringDecoder() | |
| QStringDecoder(Encoding encoding, Flags flags = Flag::Default) | |
| QStringDecoder(QAnyStringView name, Flags flags = Flag::Default) | |
| QString | operator()(QByteArrayView ba) |
| QString | operator()(const QByteArray &ba) |
| QString | decode(QByteArrayView ba) |
| qsizetype | requiredSpace(qsizetype inputLength) const |
| QChar * | appendToBuffer(QChar *out, QByteArrayView ba) |
| char16_t * | appendToBuffer(char16_t *out, QByteArrayView ba) |
Static Public Members
| QStringDecoder | decoderForHtml(QByteArrayView data) |
Detailed Description
QStringDecoder fromUtf8(QStringConverter::Utf8);
QString text = fromUtf8(chunk1);
text += fromUtf8(chunk2); // a sequence split between chunks is joined
See also QStringEncoder and QStringConverter.
Differences from Qt
operator()() and decode() return a QString directly instead of a lazily converted DecodedData object.
Member Function Documentation
QStringDecoder::QStringDecoder()
Constructs an invalid decoder.
QStringDecoder::QStringDecoder(Encoding encoding, Flags flags = Flag::Default)
Constructs a decoder for encoding with the flags flags.
QStringDecoder::QStringDecoder(QAnyStringView name, Flags flags = Flag::Default)
Constructs a decoder for the encoding called name with the flags flags. The decoder is invalid if the name is not supported.
See also encodingForName().
QChar * QStringDecoder::appendToBuffer(QChar *out, QByteArrayView ba)
Decodes ba into the buffer out, which must hold at least requiredSpace() characters, and returns a pointer just past the last character written.
char16_t * QStringDecoder::appendToBuffer(char16_t *out, QByteArrayView ba)
This is an overloaded function.
Decodes ba into the buffer out and returns a pointer just past the last character written.
QString QStringDecoder::decode(QByteArrayView ba)
Decodes ba and returns the text. Unless the decoder is Flag::Stateless, an incomplete sequence at the end of ba is kept and completed by the next call. Invalid sequences become the replacement character U+FFFD (U+0000 with Flag::ConvertInvalidToNull) and are counted as errors. A byte order mark at the start of the data is skipped unless Flag::ConvertInitialBom is set; for Utf16 and Utf32 it also selects the byte order.
See also hasError() and resetState().
QStringDecoder QStringDecoder::decoderForHtml(QByteArrayView data)
Returns a decoder for the HTML document data, using the encoding found by encodingForHtml(). The decoder is invalid if the document names an encoding that is not supported.
QString QStringDecoder::operator()(QByteArrayView ba)
Decodes ba and returns the text. Same as decode().
QString QStringDecoder::operator()(const QByteArray &ba)
This is an overloaded function.
Decodes ba and returns the text.
qsizetype QStringDecoder::requiredSpace(qsizetype inputLength) const
Returns the largest number of UTF-16 code units that decoding inputLength bytes can produce, including pending state.
See also appendToBuffer().