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       Since 7.82.0, the curl parameter is ignored. Prior to  that  there  was
24       per-handle  character  conversion  support  for some very old operating
25       systems such as TPF, but it was otherwise ignored.
26
27       You must curl_free(3) the returned string when you are done with it.
28

ENCODING

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

EXAMPLE

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

AVAILABILITY

51       Added in 7.15.4 and replaces the old curl_escape(3) function.
52

RETURN VALUE

54       A pointer to a null-terminated string or NULL if it failed.
55

SEE ALSO

57       curl_easy_unescape(3), curl_free(3), RFC3986
58
59
60
61libcurl 8.0.1                  January 02, 2023            curl_easy_escape(3)
Impressum