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're 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

AVAILABILITY

36       Added in 7.15.4 and replaces the old curl_escape(3) function.
37

RETURN VALUE

39       A pointer to a null-terminated string or NULL if it failed.
40

EXAMPLE

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

SEE ALSO

52       curl_easy_unescape(3), curl_free(3), RFC3986
53
54
55
56libcurl 7.79.1                 November 09, 2020           curl_easy_escape(3)
Impressum