c++ 打印串

__attribute__((unused))  __maybe_unused
static std::string print_sha1(const uint8_t* sha1, size_t len) {
  const char* hex = "0123456789abcdef";
  std::string result = "";
  for (size_t i = 0; i < len; ++i) {
    result.push_back(hex[(sha1[i] >> 4) & 0xf]);
    result.push_back(hex[sha1[i] & 0xf]);
  }
  return result;
}


static std::string print_a_char( uint8_t input_char ) 
{     
    const char* hex = "0123456789abcdef";
    std::string result = "";
    result.push_back( hex[(input_char >> 0x04) & 0xf] );
    result.push_back( hex[(input_char >> 0x00) & 0xf] );
    return result;
}

 

uint8_t *p;

p = (uint8_t *)data.data();

    if( (int)p[16] == 17 ){
        ;
    } else{
        LOG(ERROR) << "\n\nSendMessageInternal: packet = " << data.size();
        LOG(ERROR) << "SendMessageInternal: fd = " << fd;
        LOG(ERROR) << "SendMessageInternal: cmd1 = " << print_a_char( p[16] );
        LOG(ERROR) << "SendMessageInternal: cmd2 = " << std::hex << (int)p[16];
        LOG(ERROR) << "SendMessageInternal: cmd2 = " << std::dec << (int)p[16];
        LOG(ERROR) << "send buffer:" << print_sha1(data.data(), data.size());

//android 日志一次性能打印1024字符,超过部分应该分开来打印
    }

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值