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