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

Method decodeText

app/src/SerialStudio.cpp:1064–1077  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1062 * @brief Decodes raw bytes to a QString using the given text encoding.
1063 */
1064QString SerialStudio::decodeText(QByteArrayView bytes, SerialStudio::TextEncoding enc)
1065{
1066 if (bytes.isEmpty())
1067 return {};
1068
1069 if (const auto native = nativeEncoding(enc); native.has_value()) {
1070 QStringDecoder decoder(*native);
1071 return decoder.decode(bytes);
1072 }
1073
1074 auto* codec = legacyCodec(enc);
1075 Q_ASSERT(codec != nullptr);
1076 return codec->toUnicode(bytes.constData(), static_cast<int>(bytes.size()));
1077}

Callers

nothing calls this directly

Calls 4

nativeEncodingFunction · 0.85
legacyCodecFunction · 0.85
isEmptyMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected