title: How to make my `std::string url_encode_wstring(const std::wstring &input)` work on Linux?
body: <p>So we <a href="https://stackoverflow.com/questions/3300025/how-do-i-html-url-encode-a-stdwstring-containing-unicode-characters/3338289#3338289">have</a> such function:</p>
  
  <pre><code>std::string url_encode_wstring(const std::wstring &amp;input)
       {
           std::string output;
           int cbNeeded = WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1, NULL, 0, NULL, NULL);
           if (cbNeeded &gt; 0) {
               char *utf8 = new char[cbNeeded];
               if (WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1, utf8, cbNeeded, NULL, NULL) != 0) {
                   for (char *p = utf8; *p; *p++) {
                       char onehex[5];
                       _snprintf(onehex, sizeof(onehex), "%%%02.2X", (unsigned char)*p);
                       output.append(onehex);
                   }
               }
               delete[] utf8;
           }
           return output;
       }
  </code></pre>
  
  <p>Its grate for windows but I wonder how (and is it possible) to make it work under linux?</p>