* @brief Decodes raw bytes to a QString using the given text encoding. */
| 1062 | * @brief Decodes raw bytes to a QString using the given text encoding. |
| 1063 | */ |
| 1064 | QString 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 | } |
nothing calls this directly
no test coverage detected