curl_escape(3)

curl_escape3

Url encodes the given string

Usage

#include <curl/curl.h>
char *curl_escape(const char *string, int length);

Overview

Obsolete function. Use curl_easy_escape(3) instead!

This function converts the given input string to a URL encoded string and return that as a new allocated string. All input characters that are not a-z, A-Z or 0-9 are converted to their "URL escaped" version (%NN where NN is a two-digit hexadecimal number).

If the length argument is set to 0, curl_escape(3) uses strlen() on string to find out the size.

You must curl_free(3) the returned string when you are done with it.

Examples

int main(void)
{
  char *output = curl_escape("data to convert", 15);
  if(output) {
    printf("Encoded: %s\n", output);
    curl_free(output);
  }
}

Return value

A pointer to a null-terminated string or NULL if it failed.

Releases

155 releases since Mac OS X 10.2; the text changed 19 times.

  1. 10.2–10.2.8
  2. 10.3–10.3.9
  3. 10.4–10.4.11
  4. 10.5–10.6.2
  5. 10.6.3–10.6.8
  6. 10.7–10.7.5
  7. 10.8–10.11.6
  8. 10.12–10.12.5
  9. 10.12.6–10.14.6
  10. 10.15–11.5
  11. 12.0.1–12.2
  12. 12.3–12.5
  13. 13.0
  14. 13.1
  15. 13.2
  16. 13.3
  17. 13.4
  18. 13.5–14.1
  19. 14.2–14.4
  20. 14.5–26.5

Availability

Since 7.15.4, curl_easy_escape(3) should be used. This function might be removed in a future release.

From curl 166.0.0.0.1 in macOS 26.5. Parsed by carta from the page's man source.