KHTTP_URLENCODE(3)
π 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
NULLif 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
- Copyright (c) 2014, 2017, 2020 Kristaps Dzonsons <kristaps@bsd.lv>
- Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms