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