Possible Duplicate:
C++ convert string to hexadecimal and vice versa
Trying this sample code which I found in StackOverflow...
std::string text = "¯"; // AF in HEX ASCII.
std::ostringstream result;
result << std::setw(2) << std::setfill('0') << std::hex << std::uppercase;
std::copy(text.begin(), text.end(), std::ostream_iterator<unsigned int>(result, " "));
result.str() will be 'FFFFFFAF' instead of just 'AF'
What can I do?
My text can have more than one character, like that: text = '¯ABCÈ'; // AF414243C8 The result after 'convertion' is: FFFFFFAF414243FFFFFFC8.
.
Well, I solved it with a replace... it's not a good practice in this case, but solved.
if(value > 6)
{ //replace
std::string& str = stringlist2[count];
const std::string& from = "FFFFFF";
const std::string& to = "";
size_t j;
for ( ; (j = stringlist2[count].find( from )) != string::npos ; ) {
stringlist2[count].replace( j, from.length(), to );
}
}