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