1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: curl_escape 5Section: 3 6Source: libcurl 7See-also: 8 - curl_free (3) 9 - curl_unescape (3) 10Protocol: 11 - All 12Added-in: 7.1 13--- 14 15# NAME 16 17curl_escape - URL encode a string 18 19# SYNOPSIS 20 21~~~c 22#include <curl/curl.h> 23 24char *curl_escape(const char *string, int length); 25~~~ 26 27# DESCRIPTION 28 29Obsolete function. Use curl_easy_escape(3) instead. 30 31This function converts the given input **string** to a URL encoded string 32and return that as a new allocated string. All input characters that are not 33a-z, A-Z or 0-9 are converted to their "URL escaped" version (**%NN** where 34**NN** is a two-digit hexadecimal number). 35 36If the **length** argument is set to 0, curl_escape(3) uses strlen() 37on **string** to find out the size. 38 39You must curl_free(3) the returned string when you are done with it. 40 41# %PROTOCOLS% 42 43# EXAMPLE 44 45~~~c 46int main(void) 47{ 48 char *output = curl_escape("data to convert", 15); 49 if(output) { 50 printf("Encoded: %s\n", output); 51 curl_free(output); 52 } 53} 54~~~ 55 56# HISTORY 57 58Since 7.15.4, curl_easy_escape(3) should be used. This function might be 59removed in a future release. 60 61# %AVAILABILITY% 62 63# RETURN VALUE 64 65A pointer to a null-terminated string or NULL if it failed. 66