from small one page howto to huge articles all in one place

search text in:




Other .linuxhowtos.org sites:gentoo.linuxhowtos.org



Last additions:
using iotop to find disk usage hogs

using iotop to find disk usage hogs

words:

887

views:

209579

userrating:


May 25th. 2007:
Words

486

Views

258583

why adblockers are bad


Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

words:

161

views:

149872

userrating:


April, 26th. 2006:

Druckversion
You are here: manpages





curl_easy_escape

Section: C Library Functions (3)
Updated: 202-0-19
Index Return to Main Contents
 

NAME

curl_easy_escape - URL encode a string  

SYNOPSIS

#include <curl/curl.h>

char *curl_easy_escape(CURL *curl, const char *string, int length);
 

DESCRIPTION

This function converts the given input string to a URL encoded string and returns that as a new allocated string. All input characters that are not a-z, A-Z, 0-9, aq-aq, aq.aq, aq_aq or aq~aq are converted to their "URL escaped" version (%NN where NN is a two-digit hexadecimal number). Although not constrained by its type, the returned string may not be altered.

If length is set to 0 (zero), curl_easy_escape(3) uses strlen() on the input string to find out the size.

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

ENCODING

libcurl is typically not aware of, nor does it care about, character encodings. curl_easy_escape(3) encodes the data byte-by-byte into the URL encoded version without knowledge or care for what particular character encoding the application or the receiving server may assume that the data uses.

The caller of curl_easy_escape(3) must make sure that the data passed in to the function is encoded correctly.  

URLs

URLs are by definition URL encoded. To create a proper URL from a set of components that may not be URL encoded already, you cannot URL encode the entire URL string with curl_easy_escape(3), because it then also converts colons, slashes and other symbols that you probably want untouched.

To create a proper URL from strings that are not already URL encoded, we recommend using libcurlaqs URL API: set the pieces with curl_url_set(3) and get the final correct URL with curl_url_get(3).  

PROTOCOLS

This functionality affects all supported protocols  

EXAMPLE

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    char *output = curl_easy_escape(curl, "data to convert", 15);
    if(output) {
      printf("Encoded: %sn", output);
      curl_free(output);
    }
    curl_easy_cleanup(curl);
  }
}
 

HISTORY

Since 7.82.0, the curl parameter is ignored. Prior to that there was per-handle character conversion support for some old operating systems such as TPF, but it was otherwise ignored.  

AVAILABILITY

Added in curl 7.15.4  

RETURN VALUE

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

SEE ALSO

curl_easy_unescape(3), curl_url_get(3), curl_url_set(3)


 

Index

NAME
SYNOPSIS
DESCRIPTION
ENCODING
URLs
PROTOCOLS
EXAMPLE
HISTORY
AVAILABILITY
RETURN VALUE
SEE ALSO





Support us on Content Nation
rdf newsfeed | rss newsfeed | Atom newsfeed
- Powered by LeopardCMS - Running on Gentoo -
Copyright 2004-2025 Sascha Nitsch Unternehmensberatung GmbH
Valid XHTML1.1 : Valid CSS
- Level Triple-A Conformance to Web Content Accessibility Guidelines 1.0 -
- Copyright and legal notices -
Time to create this page: 13.8 ms