KHTTP_URLENCODE(3)

πŸ“¦ version 1.0.1, in alpine 3.24

πŸ’– KHTTP_URLENCODE πŸ’–

okay so bestie, welcome to khttp_urlencode from libkcgi β€” it's the glow-up function that takes your string and makes it URL-safe. percent-encoding slay, no cap ✨


🌸 NAME 🌸

khttp_urlencode β€” URL encoding for kcgi πŸŽ€

πŸ“š LIBRARY πŸ“š

library β€œlibkcgi” β€” yeah, the whole thing lives in there, iykyk πŸ¦‹

✨ SYNOPSIS ✨

like, include these first or it's giving compilation error πŸ’€

#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>

char *
khttp_urlencode(const char *cp);

πŸ’… DESCRIPTION πŸ’…

okay so the main character here is khttp_urlencode. it percent-encodes a string cp β€” usually so you can embed it in a URL β€” and hands you back the allocated result. so iconic of it 🫢

if you pass it a NULL? it still returns an allocated empty string. not me finding that so cute 😭 literally never crashes on you, it's so well-adjusted.

the encoding uses capital-letter hex encoding. capital letters. periodt. πŸ”₯

πŸ‘‘ RETURN VALUES πŸ‘‘

  • returns a newly-allocated string πŸŽ€ that you must free with free(3) β€” bestie please actually free it, don't leak on me πŸ™ˆ
  • returns NULL if allocation fails 😭 (it's not a vibe but it happens)
⚠️ also, just so you know: the deprecated form of this function, kutil_urlencode(), should no longer be used. it's giving old money, and not in a cute way. use this one instead πŸ’…

🌈 EXAMPLES 🌈

here's the pre- and post-encoding table, bestie β€” look at what it does to these strings πŸ”₯

foo bar   foo+bar
foo+bar   foo%2Bbar

so foo bar becomes foo+bar (space β†’ +, ate), and foo+bar becomes foo%2Bbar (the plus gets encoded as %2B β€” capital hex, told you πŸ’–). notice how the + is literally the one being escaped there, no cap. the way the same character means two different things... main character energy tbh ⭐

🧚 AUTHORS 🧚

Written by Kristaps Dzonsons <kristaps@bsd.lv>. king shit πŸ‘‘ thank you for your service 🫢


mwah ok that's the whole page bestie πŸ’œ this came from the Debian build, version $Mdocdate$, and the page itself is KHTTP_URLENCODE(3) β€” go forth and percent-encode responsibly, ily πŸŽ€πŸŒΈβœ¨

πŸ“¦ where this page comes from
  • alpine 3.24: kcgi-doc 1.0.1-r0 Β· ISC
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms