title: UTF8 data to std::string or std::wstring
body: <p>I receive the body bytes from an HTTP server response and I dont know how to convert them to an UTF8 string to work with them.</p>
  
  <p>I have an idea but I am not sure wheter it works. I need to get the bytes of the response and search on them and modify them, so I need to transform the <code>std::vector&lt;BYTE&gt;</code> to <code>std::wstring</code> or <code>std::string</code>.</p>
  
  <p>The bytes encoding in UTF8 of the response are in my <code>std::vector&lt;BYTE&gt;</code>, how can I transform them to a <code>std::string</code>? Shall I transform them to <code>std::wstring</code>?.</p>
  
  <p>I found this code:</p>
  
  <pre><code>std::string Encoding::StringToUtf8(const std::string&amp; str)
  {
  INT size = MultiByteToWideChar(CP_ACP, MB_COMPOSITE, str.c_str(), str.length(), NULL, 0);
  
  std::wstring utf16_str(size, '\0');
  
  MultiByteToWideChar(CP_ACP, MB_COMPOSITE, str.c_str(), str.length(), &amp;utf16_str[0], size);
  
  INT utf8_size = WideCharToMultiByte(CP_UTF8, 0, utf16_str.c_str(), utf16_str.length(), NULL, 0, NULL, NULL);
  
  std::string utf8_str(utf8_size, '\0');
  
  WideCharToMultiByte(CP_UTF8, 0, utf16_str.c_str(), utf16_str.length(), &amp;utf8_str[0], utf8_size, NULL, NULL);
  
  return utf8_str;
  </code></pre>
  
  <p>}</p>
  
  <p>But now if I want to search a character like "Ñ" in the string will work?, or Have I to transform the bytes in a <code>std::wstring</code> and search the "Ñ" modify the <code>std::wstring</code> and convert it to <code>std::string</code>?</p>
  
  <p>Which of the two would be correct?</p>
  
  <p>I need to put the UTF8 response in a <code>std::string</code> or <code>std::wstring</code> in order to search and modify the data (with special characters) and resend the response to the client in UTF8.</p>