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

Function legacyCodec

app/src/SerialStudio.cpp:910–942  ·  view source on GitHub ↗

* @brief Returns the `QTextCodec` for multi-byte East-Asian encodings. */

Source from the content-addressed store, hash-verified

908 * @brief Returns the `QTextCodec` for multi-byte East-Asian encodings.
909 */
910static QTextCodec* legacyCodec(SerialStudio::TextEncoding enc)
911{
912 const char* name = nullptr;
913 switch (enc) {
914 case SerialStudio::EncGbk:
915 name = "GBK";
916 break;
917 case SerialStudio::EncGb18030:
918 name = "GB18030";
919 break;
920 case SerialStudio::EncBig5:
921 name = "Big5";
922 break;
923 case SerialStudio::EncShiftJis:
924 name = "Shift_JIS";
925 break;
926 case SerialStudio::EncEucJp:
927 name = "EUC-JP";
928 break;
929 case SerialStudio::EncEucKr:
930 name = "EUC-KR";
931 break;
932 default:
933 break;
934 }
935
936 QTextCodec* codec = name ? QTextCodec::codecForName(name) : nullptr;
937 if (!codec)
938 codec = QTextCodec::codecForName("UTF-8");
939
940 Q_ASSERT(codec != nullptr);
941 return codec;
942}
943
944/**
945 * @brief Returns the display labels for all supported text encodings.

Callers 2

encodeTextMethod · 0.85
decodeTextMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected