curl/docs/libcurl/curl_escape.md
Daniel Stenberg b935fd4a07
docs: make each libcurl man specify protocol(s)
The mandatory header now has a mandatory list of protocols for which the
manpage is relevant.

Most man pages already has a "PROTOCOLS" section, but this introduces a
stricter way to specify the relevant protocols.

cd2nroff verifies that at least one protocol is mentioned (which can be
`*`).

This information is not used just yet, but A) the PROTOCOLS section can
now instead get generated and get a unified wording across all manpages
and B) this allows us to more reliably filter/search for protocol
specific manpages/options.

Closes #13166
2024-03-21 15:27:06 +01:00

1.2 KiB

c: Copyright (C) Daniel Stenberg, daniel@haxx.se, et al. SPDX-License-Identifier: curl Title: curl_escape Section: 3 Source: libcurl See-also: - curl_free (3) - curl_unescape (3) Protocol: - *

NAME

curl_escape - URL encodes the given string

SYNOPSIS

#include <curl/curl.h>

char *curl_escape(const char *string, int length);

DESCRIPTION

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.

EXAMPLE

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

AVAILABILITY

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

RETURN VALUE

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