1curl_easy_unescape(3) libcurl Manual 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 *url,
12 int inlength, int *outlength);
13
15 This function converts the given URL encoded input string to a "plain
16 string" and returns that in an allocated memory area. All input charac‐
17 ters that are URL encoded (%XX where XX is a two-digit hexadecimal num‐
18 ber) are 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 the input url string 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 an escaped
25 string containing %00 to still get used properly after unescaping.
26 Since this is a pointer to an int type, it can only return a value up
27 to INT_MAX so no longer string can be unescaped if the string length is
28 returned in this parameter.
29
30 Since 7.82.0, the curl parameter is ignored. Prior to that there was
31 per-handle character conversion support for some very old operating
32 systems such as TPF, but it was otherwise ignored.
33
34 You must curl_free(3) the returned string when you are done with it.
35
37 CURL *curl = curl_easy_init();
38 if(curl) {
39 int decodelen;
40 char *decoded = curl_easy_unescape(curl, "%63%75%72%6c", 12, &decodelen);
41 if(decoded) {
42 /* do not assume printf() works on the decoded data! */
43 printf("Decoded: ");
44 /* ... */
45 curl_free(decoded);
46 }
47 curl_easy_cleanup(curl);
48 }
49
51 Added in 7.15.4 and replaces the old curl_unescape(3) function.
52
54 A pointer to a null-terminated string or NULL if it failed.
55
57 curl_easy_escape(3), curl_free(3),RFC3986
58
59
60
61libcurl 7.85.0 July 08, 2022 curl_easy_unescape(3)