scan_urlencoded(3)

scan_urlencoded(3) πŸ’–

okay bestie, welcome to the scan_urlencoded page, straight out of the Library Functions Manual ✨


✨ NAME ✨

scan_urlencoded β€” it decodes urlencoded data, that's the whole gig πŸŽ€


🌸 SYNTAX 🌸

#include <libowfat/textcode.h>

size_t scan_urlencoded(const char *src,char *dest,size_t* destlen);

πŸ¦‹ DESCRIPTION πŸ¦‹

so scan_urlencoded takes urlencoded data from src and decodes it into dest, no cap πŸ’…

Decoding stops the moment it runs into any invalid input characters β€” and yes that includes ' ', '?' and '&' πŸ™ˆ it's giving "we're done here."

Then it writes the number of decoded bytes sitting in dest into *destlen, and returns the number of bytes it decoded from src. two numbers, one call, iconic behavior πŸ‘‘

⚠️ now listen, the plus character is handled differently depending on whether we're encoding the query part or the path (application/x-www-form-urlencoded). In "http://example.com/a+b?c+d", only the second plus can be decoded as a space character. If you want + decoded to space, use scan_urlencoded2. fr fr, don't skip this part 😭

quick facts, bestie:

  • dest can be NULL βœ…
  • destlen can be NULL βœ…
  • dest can be src (yes, in-place, main character energy) βœ…

πŸ’œ RETURN VALUE πŸ’œ

scan_urlencoded returns the number of bytes successfully scanned and processed from src. that's it, that's the tea πŸ“


🌈 EXAMPLES 🌈

scan_urlencoded("foo%3ebar",buf,&i) -> return 9, i=7, buf="foo.bar"

scan_urlencoded("foo+bar",buf,&i) -> return 7, i=7, buf="foo+bar"

scan_urlencoded2("foo+bar",buf,&i) -> return 7, i=7, buf="foo bar"

see how the + just sits there in the first +bar one? πŸ‘€ that's the whole point, and scan_urlencoded2 is the one that turns it into a space 🫢


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the page!! πŸŽ€ this was scan_urlencoded(3) from the Library Functions Manual β€” go decode something slay, mwah πŸ’‹βœ¨