scan_urlencoded2(3)
π scan_urlencoded2 β the manual, but make it make sense π
okay bestie, gather round, because today we're decoding urlencoded data and it's genuinely not that deep, i promise π«Ά this is scan_urlencoded2(3), a lil function from the Library Functions Manual, and she's basically her sister scan_urlencoded but with one β¨iconicβ¨ little twist. let's get into it.
β¨ NAME β¨
scan_urlencoded2 β decode urlencoded data π
like. that's the whole job. she decodes. she slays. periodt.
πΈ SYNTAX πΈ
first things first, you gotta bring her in:
#include <libowfat/textcode.h>
size_t scan_urlencoded2(const char *src,char *dest,size_t* destlen);
that's the include, that's the signature, that's the whole vibe check. copy it exactly, no freestyling π
π¦ DESCRIPTION π¦
so here's the tea: scan_urlencoded2 behaves like scan_urlencoded, BUT she decodes '+' to ' ' π₯ that's it. that's the plot twist. that's the entire reason she exists as her own function.
for all the actual deets, you wanna go read scan_urlencoded(3) β she's the main character, this one's her sequel, iykyk.
now, the flexibility notes, because she's chill like that:
destcan beNULLπdestlencan beNULLπdestcan besrcβ yes bestie, in-place, she's fine with it, no drama π
β RETURN VALUE β
she returns the number of bytes successfully scanned and processed from src π
that's the number. that's the receipt. don't lose it.
π EXAMPLES π
okay this is the part where it clicks, watch:
scan_urlencoded2("foo%20bar",buf,&i) -> return 9, i=7, buf="foo bar"
%20 becomes a space, she scanned 9 bytes, i lands at 7, buf is "foo bar" β¨
scan_urlencoded2("foo+bar",buf,&i) -> return 7, i=7, buf="foo bar"
here's the moment!! π the '+' becomes a space too, buf is still "foo bar", but notice the return is 7 this time, not 9, because there was no %20 eating up extra characters π§
scan_urlencoded("foo+bar",buf,&i) -> return 7, i=7, buf="foo+bar"
and THIS one is the original scan_urlencoded doing her thing β same input, but look at buf: "foo+bar" π the plus stays a plus, because that's not her job. that's the whole difference between the two of them, side by side, no cap π
π SEE ALSO π
go bother these queens next:
ngl, if you forget the'+'β' 'thing you're gonna have a bad time, so maybe reread that DESCRIPTION section, bestie π«Ά
okay that's the page!! this was scan_urlencoded2(3), straight from the Library Functions Manual, and yes the whole thing still signs off as scan_urlencoded2(3) at the bottom like the iconic lil footer she is π love that for her. go decode something, mwah ππ
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· GPL-2.0-only
- debian bookworm: libowfat-dev 0.32-4 Β· GPL-2.0-only
- debian trixie: libowfat-dev 0.32-5 Β· GPL-2.0-only
- nixos 26.05: libowfat 0.34
- nixpkgs unstable: libowfat 0.34
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- ubuntu noble: libowfat-dev 0.32-4.1build1 Β· GPL-2.0-only
- ubuntu questing: libowfat-dev 0.32-5
- ubuntu resolute: libowfat-dev 0.34-2 Β· GPL-2.0-only
- ubuntu stonking: libowfat-dev 0.34-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms