QTextEncoder Class
QTextEncoder 类提供了一个基于状态的编码器。更多
Header: | #include <QTextEncoder> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core5Compat) target_link_libraries(mytarget PRIVATE Qt6::Core5Compat) |
qmake: | QT += core5compat |
注意:该类中的所有函数都是可重入的。
公共函数
QTextEncoder(const QTextCodec *codec) | |
QTextEncoder(const QTextCodec *codec, int flags) | |
~QTextEncoder() | |
QByteArray | fromUnicode(const QString &str) |
QByteArray | fromUnicode(QStringView str) |
QByteArray | fromUnicode(const QChar *uc, int len) |
另请参阅 QTextCodec::makeEncoder() 和QTextDecoder 。
成员函数文档
[explicit]
QTextEncoder::QTextEncoder(const QTextCodec *codec)
为给定的codec 构建文本编码器。
[explicit]
QTextEncoder::QTextEncoder(const QTextCodec *codec, int flags)
为给定的codec 和转换flags 构建文本编码器。
[noexcept]
QTextEncoder::~QTextEncoder()
销毁编码器。
QByteArray QTextEncoder::fromUnicode(const QString &str)
将 Unicode 字符串str 转换为编码后的QByteArray 。
QByteArray QTextEncoder::fromUnicode(QStringView str)
这是一个重载函数。
将 Unicode 字符串str 转换为编码后的QByteArray 。
QByteArray QTextEncoder::fromUnicode(const QChar *uc, int len)
这是一个重载函数。
从uc 转换len 字符(非字节),并以QByteArray 返回结果。
© 2025 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.