vector<char>
aをaにstd::string
変換し、一方通行で変換したいと思います。
私はもうすぐそこにいますが、以下のコードの結果は、vector<string>
1つの文字列(ベクトル内のすべての文字列部分の連結)が必要な場合です。
詳細については、私のコード例を参照してください。
string ConvertHexToAscii(const char input)
{
std::ostringstream oss;
oss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(input);
return oss.str();
}
vector<char> readBuffer; // this is my input
readBuffer.push_back(0x1c);
readBuffer.push_back(0x09);
vector<string> resultVec;
std::transform(readBuffer.begin(), readBuffer.end()
, back_inserter(resultVec)
, ConvertHexToAscii);
// resultVec[0] = "1C";
// resultVec[1] = "09";
必要な結果は、「1C09」を含む文字列です。でそれを達成する方法はstd::transform
?