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