gnurl_easy_escape(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… gnurl_easy_escape(3) β€” URL encodes the given string, bestie πŸ’…

okay so this page is from the libgnurl Manual, and it’s all about curl_easy_escape β€” yes, the page itself is filed as gnurl_easy_escape(3), iykyk 🫢. It’s giving URL-encoding main character energy ✨.

🌸 NAME 🌸

  • curl_easy_escape β€” URL encodes the given string

✨ SYNOPSIS ✨

#include <gnurl/curl.h>

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

πŸŽ€ DESCRIPTION πŸŽ€

Here’s the tea, bestie: 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, '-', '.', '_' or '~' are converted to their "URL escaped" version (%NN where NN is a two-digit hexadecimal number). πŸ’…

If length is set to 0 (zero), curl_easy_escape(3) uses strlen() on the input string to find out the size. Cute, right? πŸŽ€

You must curl_free(3) the returned string when you’re done with it. Like, actually must β€” do not skip this one 🫢.

πŸ”₯ 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. That’s on you, bestie β€” the function is not doing vibe checks on encodings πŸ’€.

⭐ AVAILABILITY ⭐

Added in 7.15.4 and replaces the old curl_escape(3) function. Iconic. πŸ‘‘

🌈 RETURN VALUE 🌈

A pointer to a null-terminated string or NULL if it failed. That’s it, that’s the return value πŸŽ€.

πŸ’– EXAMPLE πŸ’–

CURL *curl = curl_easy_init();
if(curl) {
  char *output = curl_easy_escape(curl, "data to convert", 15);
  if(output) {
    printf("Encoded: %s\n", output);
    curl_free(output);
  }
}

πŸ¦‹ SEE ALSO πŸ¦‹


kisses and URL-encoded dreams πŸ’œ this page is from libcurl 7.15.4, dated 7 April 2006, and it’s filed under gnurl_easy_escape(3) 🫢

πŸ“¦ where this page comes from