1curl_easy_unescape(3)           libcurl Manual           curl_easy_unescape(3)
2
3
4

NAME

6       curl_easy_unescape - URL decodes the given string
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       char *curl_easy_unescape(CURL *curl, const char *url,
12                                int inlength, int *outlength);
13

DESCRIPTION

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       You must curl_free(3) the returned string when you are done with it.
31

EXAMPLE

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

AVAILABILITY

47       Added in 7.15.4 and replaces the old curl_unescape(3) function.
48

RETURN VALUE

50       A pointer to a null-terminated string or NULL if it failed.
51

SEE ALSO

53       curl_easy_escape(3), curl_free(3),RFC3986
54
55
56
57libcurl 7.82.0                 December 06, 2021         curl_easy_unescape(3)
Impressum