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:

  • dest can be NULL πŸ™ˆ
  • destlen can be NULL πŸ™ˆ
  • dest can be src β€” 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 πŸ’–πŸ’