C++ (Qt)void MainWindow::getShowData(QByteArray data){ txtTraffic->append(data.toHex);}
C++ (Qt)QString MainWindow::dumpFunc(QByteArray ba){ QString strStr; QString strHex; char strBufStr[4]; char strBufHex[5]; for(int i = 0; i<ba.length(); i++) { if(i%8 == 15) { ::sprintf(strBufHex,"%02X\n",(unsigned char)(ba.at(i))); if((ba.at(i) != 0 )&& ((unsigned char)(ba.at(i)) < 128)) { ::sprintf(strBufStr,"%c\n",(unsigned char)(ba.at(i))); } else { strBufStr[0] = '.'; strBufStr[1] = '\n'; strBufStr[2] = 0; } } else if(i%8 == 7) { ::sprintf(strBufHex,"%02X ",(unsigned char)(ba.at(i))); if((ba.at(i) != 0 )&& ((unsigned char)(ba.at(i)) < 128)) { ::sprintf(strBufStr,"%c ",(unsigned char)(ba.at(i))); } else { strBufStr[0] = '.'; strBufStr[1] = ' '; strBufStr[2] = ' '; strBufStr[3] = 0; } } else { ::sprintf(strBufHex,"%02X ",(unsigned char)(ba.at(i))); if((ba.at(i) != 0 )&& ((unsigned char)(ba.at(i)) < 128)) { ::sprintf(strBufStr,"%c ",(unsigned char)(ba.at(i))); } else { strBufStr[0] = '.'; strBufStr[1] = ' '; strBufStr[2] = 0; } } strHex.append(strBufHex); strStr.append(strBufStr); } strHex.append(" | "); strHex.append(strStr); return strHex;}
C++ (Qt) if(i%8 == 15)
if (tmpArray.size() > 0) { QString tmpStr2(tmpArray.toHex()); for (int i = 0; i < tmpStr2.size(); i+=3) { tmpStr2.insert(i, " "); } ui.plainTextEdit->appendPlainText(tmpStr2.toUpper()); }
C++ (Qt)QString dumpFunc(QByteArray Ba){ QString Res(""); char *T = "0123456789ABCDEF"; if (int L = Ba.size()) { char *W = new char[L*3-1]; memset(W,32,(L-1)*3); W[L*3-1] = 0; for(int i=0,p=0; i<L; i++,p++) { *(W+p++) = T[Ba[i] >> 0x4]; *(W+p++) = T[Ba[i] & 0xF]; } Res.append(W); delete W; } return Res;}