curl_easy_unescape.3 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2022, Daniel Stenberg, <[email protected]>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH curl_easy_unescape 3 "July 08, 2022" "libcurl 7.85.0" "libcurl Manual"
  26. .SH NAME
  27. curl_easy_unescape - URL decodes the given string
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. char *curl_easy_unescape(CURL *curl, const char *url,
  32. int inlength, int *outlength);
  33. .fi
  34. .SH DESCRIPTION
  35. This function converts the given URL encoded input string to a "plain string"
  36. and returns that in an allocated memory area. All input characters that are
  37. URL encoded (%XX where XX is a two-digit hexadecimal number) are converted to
  38. their binary versions.
  39. If the \fBlength\fP argument is set to 0 (zero), \fIcurl_easy_unescape(3)\fP
  40. will use strlen() on the input \fIurl\fP string to find out the size.
  41. If \fBoutlength\fP is non-NULL, the function will write the length of the
  42. returned string in the integer it points to. This allows an escaped string
  43. containing %00 to still get used properly after unescaping. Since this is a
  44. pointer to an \fIint\fP type, it can only return a value up to INT_MAX so no
  45. longer string can be unescaped if the string length is returned in this
  46. parameter.
  47. Since 7.82.0, the \fBcurl\fP parameter is ignored. Prior to that there was
  48. per-handle character conversion support for some very old operating systems
  49. such as TPF, but it was otherwise ignored.
  50. You must \fIcurl_free(3)\fP the returned string when you are done with it.
  51. .SH EXAMPLE
  52. .nf
  53. CURL *curl = curl_easy_init();
  54. if(curl) {
  55. int decodelen;
  56. char *decoded = curl_easy_unescape(curl, "%63%75%72%6c", 12, &decodelen);
  57. if(decoded) {
  58. /* do not assume printf() works on the decoded data! */
  59. printf("Decoded: ");
  60. /* ... */
  61. curl_free(decoded);
  62. }
  63. curl_easy_cleanup(curl);
  64. }
  65. .fi
  66. .SH AVAILABILITY
  67. Added in 7.15.4 and replaces the old \fIcurl_unescape(3)\fP function.
  68. .SH RETURN VALUE
  69. A pointer to a null-terminated string or NULL if it failed.
  70. .SH "SEE ALSO"
  71. .BR curl_easy_escape "(3), " curl_free "(3)," RFC 3986