quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

curl_easy_unescape.md (1890B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: curl_easy_unescape
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - curl_easy_escape (3)
      9   - curl_url_get (3)
     10 Protocol:
     11   - All
     12 Added-in: 7.15.4
     13 ---
     14 
     15 # NAME
     16 
     17 curl_easy_unescape - URL decode a string
     18 
     19 # SYNOPSIS
     20 
     21 ~~~c
     22 #include <curl/curl.h>
     23 
     24 char *curl_easy_unescape(CURL *curl, const char *input,
     25                          int inlength, int *outlength);
     26 ~~~
     27 
     28 # DESCRIPTION
     29 
     30 This function converts the URL encoded string **input** to a "plain string"
     31 and returns that in an allocated memory area. All input characters that are URL
     32 encoded (%XX where XX is a two-digit hexadecimal number) are converted to their
     33 binary versions.
     34 
     35 If the **length** argument is set to 0 (zero), curl_easy_unescape(3)
     36 uses strlen() on **input** to find out the size.
     37 
     38 If **outlength** is non-NULL, the function writes the length of the returned
     39 string in the integer it points to. This allows proper handling even for
     40 strings containing %00. Since this is a pointer to an *int* type, it can
     41 only return a value up to *INT_MAX* so no longer string can be returned in
     42 this parameter.
     43 
     44 Since 7.82.0, the **curl** parameter is ignored. Prior to that there was
     45 per-handle character conversion support for some old operating systems such as
     46 TPF, but it was otherwise ignored.
     47 
     48 You must curl_free(3) the returned string when you are done with it.
     49 
     50 # %PROTOCOLS%
     51 
     52 # EXAMPLE
     53 
     54 ~~~c
     55 int main(void)
     56 {
     57   CURL *curl = curl_easy_init();
     58   if(curl) {
     59     int decodelen;
     60     char *decoded = curl_easy_unescape(curl, "%63%75%72%6c", 12, &decodelen);
     61     if(decoded) {
     62       /* do not assume printf() works on the decoded data */
     63       printf("Decoded: ");
     64       /* ... */
     65       curl_free(decoded);
     66     }
     67     curl_easy_cleanup(curl);
     68   }
     69 }
     70 ~~~
     71 
     72 # %AVAILABILITY%
     73 
     74 # RETURN VALUE
     75 
     76 A pointer to a null-terminated string or NULL if it failed.