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

NAME

6       curl_easy_escape - URL encodes the given string
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       char *curl_easy_escape(CURL *curl, const char *string, int length);
12

DESCRIPTION

14       This  function  converts the given input string to a URL encoded string
15       and returns that as a new allocated string. All input  characters  that
16       are not a-z, A-Z, 0-9, '-', '.', '_' or '~' are converted to their "URL
17       escaped" version (%NN where NN is a two-digit hexadecimal number).
18
19       If length is set to 0 (zero), curl_easy_escape(3) uses strlen() on  the
20       input  string to find out the size. This function does not accept input
21       strings longer than CURL_MAX_INPUT_LENGTH (8 MB).
22
23       You must curl_free(3) the returned string when you are done with it.
24

ENCODING

26       libcurl is typically not aware of, nor does it  care  about,  character
27       encodings.  curl_easy_escape(3)  encodes the data byte-by-byte into the
28       URL encoded version without knowledge or care for what particular char‐
29       acter  encoding the application or the receiving server may assume that
30       the data uses.
31
32       The caller of curl_easy_escape(3) must make sure that the  data  passed
33       in to the function is encoded correctly.
34

EXAMPLE

36       CURL *curl = curl_easy_init();
37       if(curl) {
38         char *output = curl_easy_escape(curl, "data to convert", 15);
39         if(output) {
40           printf("Encoded: %s\n", output);
41           curl_free(output);
42         }
43         curl_easy_cleanup(curl);
44       }
45

AVAILABILITY

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

RETURN VALUE

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

SEE ALSO

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