p26001-store-acs-soc-fw-app/util/HexBinaryCodec.cpp
2026-09-28 21:33:04 +08:00

29 lines
894 B
C++
Executable file

/*
*******************************************************************************
* INCLUDE
*******************************************************************************
*/
#include "HexBinaryCodec.h"
#include <sstream>
#include <Poco/HexBinaryEncoder.h>
namespace Util
{
/*
*******************************************************************************
* CLASS DEFINE
*******************************************************************************
*/
std::string HexBinaryCodec::encode(const void* data, unsigned size, bool uppercase)
{
std::ostringstream ostr;
Poco::HexBinaryEncoder encoder(ostr);
encoder.rdbuf()->setUppercase(uppercase);
uint8_t* pBytes = (uint8_t*)data;
for (unsigned i = 0; i < size; i++)
encoder << pBytes[i];
encoder.close();
return ostr.str();
}
}