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_easy_unescape 5*6236dae4SAndroid Build Coastguard WorkerSection: 3 6*6236dae4SAndroid Build Coastguard WorkerSource: libcurl 7*6236dae4SAndroid Build Coastguard WorkerSee-also: 8*6236dae4SAndroid Build Coastguard Worker - curl_easy_escape (3) 9*6236dae4SAndroid Build Coastguard Worker - curl_url_get (3) 10*6236dae4SAndroid Build Coastguard WorkerProtocol: 11*6236dae4SAndroid Build Coastguard Worker - All 12*6236dae4SAndroid Build Coastguard WorkerAdded-in: 7.15.4 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_easy_unescape - URL decode 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_easy_unescape(CURL *curl, const char *input, 25*6236dae4SAndroid Build Coastguard Worker int inlength, int *outlength); 26*6236dae4SAndroid Build Coastguard Worker~~~ 27*6236dae4SAndroid Build Coastguard Worker 28*6236dae4SAndroid Build Coastguard Worker# DESCRIPTION 29*6236dae4SAndroid Build Coastguard Worker 30*6236dae4SAndroid Build Coastguard WorkerThis function converts the URL encoded string **input** to a "plain string" 31*6236dae4SAndroid Build Coastguard Workerand returns that in an allocated memory area. All input characters that are URL 32*6236dae4SAndroid Build Coastguard Workerencoded (%XX where XX is a two-digit hexadecimal number) are converted to their 33*6236dae4SAndroid Build Coastguard Workerbinary versions. 34*6236dae4SAndroid Build Coastguard Worker 35*6236dae4SAndroid Build Coastguard WorkerIf the **length** argument is set to 0 (zero), curl_easy_unescape(3) 36*6236dae4SAndroid Build Coastguard Workeruses strlen() on **input** to find out the size. 37*6236dae4SAndroid Build Coastguard Worker 38*6236dae4SAndroid Build Coastguard WorkerIf **outlength** is non-NULL, the function writes the length of the returned 39*6236dae4SAndroid Build Coastguard Workerstring in the integer it points to. This allows proper handling even for 40*6236dae4SAndroid Build Coastguard Workerstrings containing %00. Since this is a pointer to an *int* type, it can 41*6236dae4SAndroid Build Coastguard Workeronly return a value up to *INT_MAX* so no longer string can be returned in 42*6236dae4SAndroid Build Coastguard Workerthis parameter. 43*6236dae4SAndroid Build Coastguard Worker 44*6236dae4SAndroid Build Coastguard WorkerSince 7.82.0, the **curl** parameter is ignored. Prior to that there was 45*6236dae4SAndroid Build Coastguard Workerper-handle character conversion support for some old operating systems such as 46*6236dae4SAndroid Build Coastguard WorkerTPF, but it was otherwise ignored. 47*6236dae4SAndroid Build Coastguard Worker 48*6236dae4SAndroid Build Coastguard WorkerYou must curl_free(3) the returned string when you are done with it. 49*6236dae4SAndroid Build Coastguard Worker 50*6236dae4SAndroid Build Coastguard Worker# %PROTOCOLS% 51*6236dae4SAndroid Build Coastguard Worker 52*6236dae4SAndroid Build Coastguard Worker# EXAMPLE 53*6236dae4SAndroid Build Coastguard Worker 54*6236dae4SAndroid Build Coastguard Worker~~~c 55*6236dae4SAndroid Build Coastguard Workerint main(void) 56*6236dae4SAndroid Build Coastguard Worker{ 57*6236dae4SAndroid Build Coastguard Worker CURL *curl = curl_easy_init(); 58*6236dae4SAndroid Build Coastguard Worker if(curl) { 59*6236dae4SAndroid Build Coastguard Worker int decodelen; 60*6236dae4SAndroid Build Coastguard Worker char *decoded = curl_easy_unescape(curl, "%63%75%72%6c", 12, &decodelen); 61*6236dae4SAndroid Build Coastguard Worker if(decoded) { 62*6236dae4SAndroid Build Coastguard Worker /* do not assume printf() works on the decoded data */ 63*6236dae4SAndroid Build Coastguard Worker printf("Decoded: "); 64*6236dae4SAndroid Build Coastguard Worker /* ... */ 65*6236dae4SAndroid Build Coastguard Worker curl_free(decoded); 66*6236dae4SAndroid Build Coastguard Worker } 67*6236dae4SAndroid Build Coastguard Worker curl_easy_cleanup(curl); 68*6236dae4SAndroid Build Coastguard Worker } 69*6236dae4SAndroid Build Coastguard Worker} 70*6236dae4SAndroid Build Coastguard Worker~~~ 71*6236dae4SAndroid Build Coastguard Worker 72*6236dae4SAndroid Build Coastguard Worker# %AVAILABILITY% 73*6236dae4SAndroid Build Coastguard Worker 74*6236dae4SAndroid Build Coastguard Worker# RETURN VALUE 75*6236dae4SAndroid Build Coastguard Worker 76*6236dae4SAndroid Build Coastguard WorkerA pointer to a null-terminated string or NULL if it failed. 77