將string字串轉化為16進位制字串
阿新 • • 發佈:2018-11-30
std::string ConverToHexString(const char *in_pData,unsigned int in_uiLen)
{
std::string tmp_strHexValue;
for (unsigned int i = 0; i < in_uiLen; ++i)
{
char tmp_szVaule[4] = { 0 };
//SEGCC::safe_sprintf(tmp_szVaule, 4, "%02X ", (unsigned char)pmessagedate[i]);
sprintf_s(tmp_szVaule, "%02X ", (unsigned char)in_pData[i]);
tmp_strHexValue += tmp_szVaule;
}
return tmp_strHexValue;
{
std::string tmp_strHexValue;
for (unsigned int i = 0; i < in_uiLen; ++i)
{
char tmp_szVaule[4] = { 0 };
//SEGCC::safe_sprintf(tmp_szVaule, 4, "%02X ", (unsigned char)pmessagedate[i]);
sprintf_s(tmp_szVaule, "%02X ", (unsigned char)in_pData[i]);
tmp_strHexValue += tmp_szVaule;
}
return tmp_strHexValue;
}
mian()
{
std::string tmp_strHexValuetest = CApiAdapter::GetInstance().ConverToHexString(pmessagedate, textlen);
CLOG_WRITE(MODULE_TAG_STRING, CSystemLog::LOG_INFO, "SendGBKData():utf8 data:%s", tmp_strHexValuetest.c_str());
}