gnurl_easy_unescape(3)

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

πŸ’… gnurl_easy_unescape β€” the URL decoder bestie we all need ✨

Okay so real talk, this is a page from the libgnurl Manual, and it's all about one little function that un-escapes URL-encoded strings for you. Think of it as the glow-up machine for ugly %XX-laden text. 🫢


🌸 NAME 🌸

curl_easy_unescape β€” literally decodes a URL-encoded string back into a plain one. No cap. πŸ’–


✨ SYNOPSIS ✨

#include <gnurl/curl.h>

char *curl_easy_unescape( CURL *curl, const char *url , int inlength,
       int *outlength );

Slay, that's the whole signature. Yes the spacing is a lil quirky, but it's iconic and we keep it exactly like that. πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

So what does this actually do? Bestie, it takes the URL-encoded input string you hand it and converts it into a "plain string", then returns that in a chunk of allocated memory. Every single input character that's URL encoded β€” meaning %XX where XX is a two-digit hexadecimal number β€” gets converted to its binary version. That's the whole vibe. ✨

If the length argument is set to 0 (zero), then curl_easy_unescape(3) is gonna call strlen() on the input url string to figure out the size for you. So you don't have to count, it's got you. πŸ’…

If outlength is non-NULL, the function writes the length of the returned string into the integer it points to. Why do we care? Because this is what allows an escaped string containing %00 to still get used properly after unescaping β€” otherwise that null byte would be a whole mess. And listen: since this is a pointer to an int type, it can only return a value up to INT_MAX, so no longer string can be unescaped if the string length is returned in this parameter. That's a hard limit, not a vibe check. 😭

⚠️ You must curl_free(3) the returned string when you're done with it. Not optional, not a suggestion. Free your memory, babes. 🧚

πŸ‘‘ AVAILABILITY πŸ‘‘

Added in 7.15.4 and it replaces the old curl_unescape(3) function. So it's the newer, cooler, main-character version. πŸ”₯


πŸ’œ RETURN VALUE πŸ’œ

A pointer to a null-terminated string, or NULL if it failed. That's it. Either it ate and left no crumbs, or it flopped with NULL. πŸ’€


🌈 SEE ALSO 🌈

Go read those if you wanna be thorough, iykyk. πŸ“


Okay that's the whole page! This one's from libcurl 7.15.4, dated 7 April 2006 β€” so like, vintage but still iconic. Bye bestie, go unescape something! πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from