1curl_easy_unescape(3) libcurl curl_easy_unescape(3)
2
3
4
6 curl_easy_unescape - URL decodes the given string
7
9 #include <curl/curl.h>
10
11 char *curl_easy_unescape(CURL *curl, const char *input,
12 int inlength, int *outlength);
13
15 This function converts the URL encoded string input to a "plain string"
16 and returns that in an allocated memory area. All input characters that
17 are URL encoded (%XX where XX is a two-digit hexadecimal number) are
18 converted to their binary versions.
19
20 If the length argument is set to 0 (zero), curl_easy_unescape(3) will
21 use strlen() on input to find out the size.
22
23 If outlength is non-NULL, the function will write the length of the re‐
24 turned string in the integer it points to. This allows proper handling
25 even for strings containing %00. Since this is a pointer to an int
26 type, it can only return a value up to INT_MAX so no longer string can
27 be returned in this parameter.
28
29 Since 7.82.0, the curl parameter is ignored. Prior to that there was
30 per-handle character conversion support for some very old operating
31 systems such as TPF, but it was otherwise ignored.
32
33 You must curl_free(3) the returned string when you are done with it.
34
36 CURL *curl = curl_easy_init();
37 if(curl) {
38 int decodelen;
39 char *decoded = curl_easy_unescape(curl, "%63%75%72%6c", 12, &decodelen);
40 if(decoded) {
41 /* do not assume printf() works on the decoded data! */
42 printf("Decoded: ");
43 /* ... */
44 curl_free(decoded);
45 }
46 curl_easy_cleanup(curl);
47 }
48
50 Added in 7.15.4 and replaces the old curl_unescape(3) function.
51
53 A pointer to a null-terminated string or NULL if it failed.
54
56 curl_easy_escape(3), curl_free(3),RFC3986
57
58
59
60libcurl 8.2.1 April 26, 2023 curl_easy_unescape(3)