curl_easy_unescape.3 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. .\" generated by cd2nroff 0.1 from curl_easy_unescape.md
  2. .TH curl_easy_unescape 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_easy_unescape \- URL decode a string
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. char *curl_easy_unescape(CURL *curl, const char *input,
  9. int inlength, int *outlength);
  10. .fi
  11. .SH DESCRIPTION
  12. This function converts the URL encoded string \fBinput\fP to a "plain string"
  13. and returns that in an allocated memory area. All input characters that are URL
  14. encoded (%XX where XX is a two\-digit hexadecimal number) are converted to their
  15. binary versions.
  16. If the \fBlength\fP argument is set to 0 (zero), \fIcurl_easy_unescape(3)\fP
  17. uses strlen() on \fBinput\fP to find out the size.
  18. If \fBoutlength\fP is non\-NULL, the function writes the length of the returned
  19. string in the integer it points to. This allows proper handling even for
  20. strings containing %00. Since this is a pointer to an \fIint\fP type, it can
  21. only return a value up to \fIINT_MAX\fP so no longer string can be returned in
  22. this parameter.
  23. Since 7.82.0, the \fBcurl\fP parameter is ignored. Prior to that there was
  24. per\-handle character conversion support for some old operating systems such as
  25. TPF, but it was otherwise ignored.
  26. You must \fIcurl_free(3)\fP the returned string when you are done with it.
  27. .SH PROTOCOLS
  28. This functionality affects all supported protocols
  29. .SH EXAMPLE
  30. .nf
  31. int main(void)
  32. {
  33. CURL *curl = curl_easy_init();
  34. if(curl) {
  35. int decodelen;
  36. char *decoded = curl_easy_unescape(curl, "%63%75%72%6c", 12, &decodelen);
  37. if(decoded) {
  38. /* do not assume printf() works on the decoded data! */
  39. printf("Decoded: ");
  40. /* ... */
  41. curl_free(decoded);
  42. }
  43. curl_easy_cleanup(curl);
  44. }
  45. }
  46. .fi
  47. .SH AVAILABILITY
  48. Added in curl 7.15.4
  49. .SH RETURN VALUE
  50. A pointer to a null\-terminated string or NULL if it failed.
  51. .SH SEE ALSO
  52. .BR curl_easy_escape (3),
  53. .BR curl_url_get (3)