Quote Originally Posted by wysota View Post
You can iterate through the string and convert all %xx matches to their hexadecimal value.

So..... i can read cookie on window .... i hope is run on Mac & Linux ...

Qt Code:
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4.  
  5.  
  6. #define SPC_BASE16_TO_10(x) (((x) >= '0' && (x) <= '9') ? ((x) - '0') : \
  7. (toupper((x)) - 'A' + 10))
  8.  
  9. QString Url_Decode( QString indata )
  10. {
  11. QByteArray lop = indata.toAscii();
  12. char *newstrings = lop.data();
  13. char *resulter = spc_decode_url(newstrings);
  14. QString salt = QString("%1").arg(resulter);
  15. QString resoap = salt.replace("+"," ");
  16. return resoap;
  17. }
  18. /* found http://www.oreillynet.com/pub/a/network/excerpt/spcookbook_chap03/index2.html */
  19. char *spc_decode_url(const char *url) {
  20. char *out, *ptr;
  21. const char *c;
  22.  
  23. if (!(out = ptr = strdup(url))) return 0;
  24. for (c = url; *c; c++) {
  25. if (*c != '%' || !isxdigit(c[1]) || !isxdigit(c[2])) *ptr++ = *c;
  26. else {
  27. *ptr++ = (SPC_BASE16_TO_10(c[1]) * 16) + (SPC_BASE16_TO_10(c[2]));
  28. c += 2;
  29. }
  30. }
  31. *ptr = 0;
  32. if ( strlen(url) == (ptr - out)); /* does not include null byte */
  33. return out;
  34. }
To copy to clipboard, switch view to plain text mode