scan_cescape(3)

✨ scan_cescape β€” NAME ✨

okay bestie, gather round πŸ’– this one's scan_cescape from section 3 of the Library Functions Manual, and its whole job is literally just parse C escaped string. that's it. that's the vibe. πŸŽ€


πŸ¦‹ SYNTAX πŸ¦‹

first you gotta invite it in:

#include <libowfat/textcode.h>

then the actual signature, no cap:

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

πŸ’… DESCRIPTION πŸ’…

so like. scan_cescape parses C escaped text out of src and drops it into dest. it's giving little translator fairy 🧚

parsing stops when it hits:

  • the 0 terminator
  • invalid input characters
  • a double quote that was not escaped

and then β€” the glow up β€” C escape sequences like \n and \x0a and \012 get translated into their binary counterparts. periodt. πŸ’…

the C99 escape sequences \u and \U are also supported (iconic of them honestly) and those lead to UTF-8 sequences being output ✨

after that, scan_cescape writes the number of bytes in dest into *destlen, and returns the number of bytes decoded from src. two numbers, one function, main character energy fr fr πŸ‘‘

now the flexible part, and it's lowkey wild:

  • dest can be NULL.
  • destlen can be NULL.
  • dest can be src.
🌸 bestie if you're worried about dest not being big enough: either allocate strlen(src)+1 bytes, or call scan_cescape twice β€” the first time with dest == NULL. and yes, *destlen will still be written even then. we love a reconnaissance mission πŸ•΅οΈβ™€οΈ

πŸ”₯ RETURN VALUE πŸ”₯

scan_cescape returns the number of bytes successfully parsed from src. that's the receipt, keep it 🧾


🌈 EXAMPLES 🌈

scan_cescape("test\n

(yes that's the whole example, it's a little mysterious, it's giving cliffhanger 😭)


πŸ‘‘ SEE ALSO πŸ‘‘

go read those next, iykyk 🫢


k bye love u, this was scan_cescape(3) from the Library Functions Manual β€” section 3, the library functions girlies πŸ’– ⭐