MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / encodeText

Method encodeText

app/src/SerialStudio.cpp:1046–1059  ·  view source on GitHub ↗

* @brief Encodes a QString to raw bytes using the given text encoding. */

Source from the content-addressed store, hash-verified

1044 * @brief Encodes a QString to raw bytes using the given text encoding.
1045 */
1046QByteArray SerialStudio::encodeText(const QString& text, SerialStudio::TextEncoding enc)
1047{
1048 if (text.isEmpty())
1049 return {};
1050
1051 if (const auto native = nativeEncoding(enc); native.has_value()) {
1052 QStringEncoder encoder(*native);
1053 return QByteArray(encoder.encode(text));
1054 }
1055
1056 auto* codec = legacyCodec(enc);
1057 Q_ASSERT(codec != nullptr);
1058 return codec->fromUnicode(text);
1059}
1060
1061/**
1062 * @brief Decodes raw bytes to a QString using the given text encoding.

Callers

nothing calls this directly

Calls 3

nativeEncodingFunction · 0.85
legacyCodecFunction · 0.85
isEmptyMethod · 0.80

Tested by

no test coverage detected