int len = hex.length();
std::string newString;
for(int i=0; i< len; i+=2)
{
std::string byte = hex.substr(i,2);
char chr = (char) (int)strtol(byte.c_str(), null, 16);
newString.push_back(chr);
}
More Related Contents:
- Parsing a comma-delimited std::string [duplicate]
- Remove spaces from std::string in C++
- Why should one not derive from c++ std string class?
- How to implode a vector of strings into a string (the elegant way)
- Case insensitive std::string.find()
- Why does C++ allow an integer to be assigned to a string?
- Is it reasonable to use std::basic_string as a contiguous buffer when targeting C++03?
- Why can’t I write to a string literal while I *can* write to a string object?
- std::strings’s capacity(), reserve() & resize() functions
- How to read and write a STL C++ string?
- initializing std::string from char* without copy
- std::string length() and size() member functions
- Why doesn’t std::string provide implicit conversion to char*?
- How can I make the map::find operation case insensitive?
- What is the difference between palindrome permutation and permutation? [closed]
- What are the mechanics of short string optimization in libc++?
- How do I convert a double into a string in C++?
- Is it safe to assume that STL vector storage is always contiguous?
- Fastest way to get IPv4 address from string
- Efficient way of reading a file into an std::vector?
- Removing item from vector while iterating?
- C++ valarray vs. vector
- vector or map, which one to use?
- STL vector and thread-safety
- Adding types to the std namespace
- What the point of using std::ios_base::binary?
- Copying std::vector: prefer assignment or std::copy?
- Do STL iterators guarantee validity after collection was changed?
- Are lambdas inlined like functions in C++?
- What’s the difference between istringstream, ostringstream and stringstream? / Why not use stringstream in every case?