In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use the Qt function body". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use the Qt function body".
Function name / / byte array to Ascii string static QString byteArrayToAsciiStr (const QByteArray & data); / / hexadecimal string to byte array static QByteArray hexStrToByteArray (const QString & str); static char convertHexChar (char ch); / / Ascii string to byte array static QByteArray asciiStrToByteArray (const QString & str); / / byte array to hexadecimal string static QString byteArrayToHexStr (const QByteArray & data) Function body QString QUIHelper::byteArrayToAsciiStr (const QByteArray & data) {QString temp; int len = data.size (); for (int I = 0; I
< len; i++) { //0x20为空格,空格以下都是不可见字符 char b = data.at(i); if (0x00 == b) { temp += QString("\\NUL"); } else if (0x01 == b) { temp += QString("\\SOH"); } else if (0x02 == b) { temp += QString("\\STX"); } else if (0x03 == b) { temp += QString("\\ETX"); } else if (0x04 == b) { temp += QString("\\EOT"); } else if (0x05 == b) { temp += QString("\\ENQ"); } else if (0x06 == b) { temp += QString("\\ACK"); } else if (0x07 == b) { temp += QString("\\BEL"); } else if (0x08 == b) { temp += QString("\\BS"); } else if (0x09 == b) { temp += QString("\\HT"); } else if (0x0A == b) { temp += QString("\\LF"); } else if (0x0B == b) { temp += QString("\\VT"); } else if (0x0C == b) { temp += QString("\\FF"); } else if (0x0D == b) { temp += QString("\\CR"); } else if (0x0E == b) { temp += QString("\\SO"); } else if (0x0F == b) { temp += QString("\\SI"); } else if (0x10 == b) { temp += QString("\\DLE"); } else if (0x11 == b) { temp += QString("\\DC1"); } else if (0x12 == b) { temp += QString("\\DC2"); } else if (0x13 == b) { temp += QString("\\DC3"); } else if (0x14 == b) { temp += QString("\\DC4"); } else if (0x15 == b) { temp += QString("\\NAK"); } else if (0x16 == b) { temp += QString("\\SYN"); } else if (0x17 == b) { temp += QString("\\ETB"); } else if (0x18 == b) { temp += QString("\\CAN"); } else if (0x19 == b) { temp += QString("\\EM"); } else if (0x1A == b) { temp += QString("\\SUB"); } else if (0x1B == b) { temp += QString("\\ESC"); } else if (0x1C == b) { temp += QString("\\FS"); } else if (0x1D == b) { temp += QString("\\GS"); } else if (0x1E == b) { temp += QString("\\RS"); } else if (0x1F == b) { temp += QString("\\US"); } else if (0x7F == b) { temp += QString("\\x7F"); } else if (0x5C == b) { temp += QString("\\x5C"); } else if (0x20 >= b) {temp + = QString ("\\ x% 1") .arg (decimalToStrHex ((quint8) b));} else {temp + = QString ("% 1") .arg (b);}} return temp.trimmed ();} QByteArray QUIHelper::hexStrToByteArray (const QString & str) {QByteArray senddata; int hexdata, lowhexdata; int hexdatalen = 0; int len = str.length () Senddata.resize (len / 2); char lstr, hstr; for (int I = 0; I
< len;) { hstr = str.at(i).toLatin1(); if (hstr == ' ') { i++; continue; } i++; if (i >= len) {break;} lstr = str.at (I). ToLatin1 (); hexdata = convertHexChar (hstr); lowhexdata = convertHexChar (lstr); if ((hexdata = = 16) | | (lowhexdata = = 16)) {break;} else {hexdata = hexdata * 16 + lowhexdata;} iTunes; senddata [hexdatalen] = (char) hexdata Hexdatalen++;} senddata.resize (hexdatalen); return senddata;} char QUIHelper::convertHexChar (char ch) {if ((ch > ='0') & & (ch ='A') & (ch ='a') & & (ch)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.