2
0

curl_easy_unescape.3 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, 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 "7 April 2006" "libcurl" "libcurl"
  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 *input,
  32. int inlength, int *outlength);
  33. .fi
  34. .SH DESCRIPTION
  35. This function converts the URL encoded string \fBinput\fP to a "plain string"
  36. and returns that in an allocated memory area. All input characters that are URL
  37. encoded (%XX where XX is a two-digit hexadecimal number) are converted to their
  38. binary versions.
  39. If the \fBlength\fP argument is set to 0 (zero), \fIcurl_easy_unescape(3)\fP
  40. will use strlen() on \fBinput\fP 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 proper handling even
  43. for strings containing %00. Since this is a pointer to an \fIint\fP type, it
  44. can only return a value up to \fIINT_MAX\fP so no longer string can be
  45. returned in this parameter.
  46. Since 7.82.0, the \fBcurl\fP parameter is ignored. Prior to that there was
  47. per-handle character conversion support for some very old operating systems
  48. such as TPF, but it was otherwise ignored.
  49. You must \fIcurl_free(3)\fP the returned string when you are done with it.
  50. .SH EXAMPLE
  51. .nf
  52. CURL *curl = curl_easy_init();
  53. if(curl) {
  54. int decodelen;
  55. char *decoded = curl_easy_unescape(curl, "%63%75%72%6c", 12, &decodelen);
  56. if(decoded) {
  57. /* do not assume printf() works on the decoded data! */
  58. printf("Decoded: ");
  59. /* ... */
  60. curl_free(decoded);
  61. }
  62. curl_easy_cleanup(curl);
  63. }
  64. .fi
  65. .SH AVAILABILITY
  66. Added in 7.15.4 and replaces the old \fIcurl_unescape(3)\fP function.
  67. .SH RETURN VALUE
  68. A pointer to a null-terminated string or NULL if it failed.
  69. .SH "SEE ALSO"
  70. .BR curl_easy_escape "(3), " curl_free "(3)," RFC 3986