QTextDecoder Class
QTextDecoder 类提供了一个基于状态的解码器。更多内容...
| 头文件: | #include <QTextDecoder> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core5Compat) target_link_libraries(mytarget PRIVATE Qt6::Core5Compat) |
| qmake: | QT += core5compat |
注意:该类中的所有函数均为可重入函数。
公共函数
| QTextDecoder(const QTextCodec *codec) | |
| QTextDecoder(const QTextCodec *codec, int flags) | |
| ~QTextDecoder() | |
| QString | toUnicode(const char *chars, int len) |
| QString | toUnicode(const QByteArray &ba) |
| void | toUnicode(QString *target, const char *chars, int len) |
另请参阅 QTextCodec::makeDecoder() 和QTextEncoder 。
成员函数文档
[explicit] QTextDecoder::QTextDecoder(const QTextCodec *codec)
根据给定的codec 构建一个文本解码器。
[explicit] QTextDecoder::QTextDecoder(const QTextCodec *codec, int flags)
根据给定的codec 和转换规则flags 构建一个文本解码器。
[noexcept] QTextDecoder::~QTextDecoder()
摧毁解码器。
QString QTextDecoder::toUnicode(const char *chars, int len)
将chars 中的前len 字节转换为Unicode,并返回结果。
如果未使用所有字符(例如,当字符末尾仅包含多字节编码的一部分时),解码器会保存足够的状态信息,以便在下次调用该函数时继续处理。
QString QTextDecoder::toUnicode(const QByteArray &ba)
将ba 指定的字节数组中的字节转换为Unicode,并返回结果。
这是一个重载函数。
void QTextDecoder::toUnicode(QString *target, const char *chars, int len)
转换后的字符串将通过target 返回。
这是一个重载函数。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.