0

I am trying to encode this URL into a cpp string:

myproject://myresponse/?token=QSDK%2031d8695d&userId=123

I need to store QSDK token in my database, but as you can see there is %20 after "QSDK", I need to convert that %20 into "space character" and store the QSDK token in my DB in this form: "QSDK 31d8695d" . Can someone please help me with this? Is there any built in function to convert url encoding into normal string in cpp? I know there is always an option to find %20 after QSDK and replace it by space but it is not good way. Can you please suggest if any built in functions exist.

I am using wxWidgets, is there any function from wxURI or simialr class which I can use for my purpose?

aromahola
  • 190
  • 1
  • 12
  • 1
    Possible duplicate of [Encode/Decode URLs in C++](https://stackoverflow.com/questions/154536/encode-decode-urls-in-c) – Cinder Biscuits Oct 16 '18 at 12:01
  • what would be the problem with [string replace](http://www.cplusplus.com/reference/string/string/replace/)? – Leonardo Alves Machado Oct 16 '18 at 12:02
  • 1
    @LeonardoAlvesMachado many prog languages have built in functions for url encode and decode, so I thought cpp will also have built in functions/libraries. – aromahola Oct 16 '18 at 12:05
  • Well, according to the first comment, there are some options for you... – Leonardo Alves Machado Oct 16 '18 at 14:18
  • See [wxURI::Unescape](https://docs.wxwidgets.org/trunk/classwx_u_r_i.html#a518f0a025e80aa83f0b6b0c0dd8f51c5). Also [wxString::Replace](https://docs.wxwidgets.org/trunk/classwx_string.html#a5517e2b01e8da1a7a92400028f1a8344) with `strOld = "%20"` and `strNew= " "` – Ripi2 Oct 16 '18 at 18:28

0 Answers0