How to convert a string in hexadecimal string?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3381614/c-convert-string-to-hexadecimal-and-vice-versa">C++ convert string to hexadecimal and vice versa</a>  </p>
</blockquote>



<p>Trying this sample code which I found in StackOverflow...</p>

<pre><code>std::string text = "¯"; // AF in HEX ASCII. 
std::ostringstream result;  
result &lt;&lt; std::setw(2) &lt;&lt; std::setfill('0') &lt;&lt; std::hex &lt;&lt; std::uppercase;  
std::copy(text.begin(), text.end(), std::ostream_iterator&lt;unsigned int&gt;(result, " "));  
</code></pre>

<p>result.str() will be 'FFFFFFAF' instead of just 'AF'</p>

<p>What can I do?</p>

<p>My text can have more than one character, like that: text = '¯ABCÈ'; // AF414243C8
The result after 'convertion' is: FFFFFFAF414243FFFFFFC8.</p>

<p>.</p>

<p>Well, I solved it with a replace... it's not a good practice in this case, but solved.</p>

<pre><code>                    if(value &gt; 6)
                    {   //replace
                        std::string&amp; str = stringlist2[count];
                        const std::string&amp; from = "FFFFFF";
                        const std::string&amp; to = "";
                        size_t j;
                        for ( ; (j = stringlist2[count].find( from )) != string::npos ; ) {
                            stringlist2[count].replace( j, from.length(), to );
                        }
                    }
</code></pre>
