qlibs:(fmt)
β¨ NAME β¨
okay so this is the qlibs:(fmt) manual page, and fmt is literally the whole βASCII representation of strings and integersβ situation β bestie, itβs giving low-level string-and-number realness π
π οΈ SYNTAX π οΈ
#include "fmt.h"
unsigned int fmt_str(char *dest,const char *source);
unsigned int fmt_strn(char *dest,const char *source,unsigned int
maxlen);
unsigned int fmt_uint(char *dest,unsigned int source);
unsigned int fmt_uint0(char *dest,unsigned int source,unsigned int n);
unsigned int fmt_ulong(char *dest,unsigned long source);
unsigned int fmt_xlong(char *dest,unsigned long source);
char tohex(char num);
int fromhex(unsigned char c);
π DESCRIPTION π
fmt_strβ copies all the leading nonzero bytes fromsourcetodest, then returns the number of bytes it copied. It does not append\0, bestie.fmt_strnβ copies at mostmaxlenleading nonzero bytes fromsourcetodest, then returns the number of bytes it copied. It does not append\0either.fmt_uintβ writes an ASCII representation ('0'to'9', base 10) ofsourcetodest, then returns the number of bytes written.fmt_uintdoes not append\0.fmt_uint0β writes an ASCII representation ('0'to'9', base 10) ofsourcetodest, then returns the number of bytes written. The output is padded with'0'-bytes until it encompasses at leastnbytes, but it will not be truncated if it does not fit.fmt_uint0does not append\0.fmt_ulongβ writes an ASCII representation ('0'to'9', base 10) ofsourcetodest, then returns the number of bytes written, perhaps including a trailing\0.fmt_ulongdoes not append\0.
β οΈ yes, the page literally says βperhaps including a trailing\0β and then βdoes not append\0β β Iβm not fixing the wording, Iβm just reporting the tea π
fmt_xlongβ writes an ASCII representation ('0'to'9'and'a'to'f', base 16) ofsourcetodest, then returns the number of bytes written.fmt_xlongdoes not append\0.tohexβ reads the ASCII representation of a decimalnumand returns its hexadecimal ASCII value. ThusΒ΄0Β΄ -> Β΄0Β΄ ... Β΄9Β΄ -> Β΄9Β΄, Β΄10Β΄ -> Β΄aΒ΄ and finally Β΄15Β΄ -> f'. iconic little mapping, no cap.fromhexβ reads theACSIIrepresentation of a hexadecimal numberΒ΄0Β΄toΒ΄fΒ΄, irrelevant of its case, and returns its integer value. (yes,ACSIIβ thatβs what the page says π«Ά)
For convenience, fmt.h defines the integers FMT_LEN and FMT_ULONG to be big enough to the number of bytes it would have written.
π§ GENERICS π§
For the functions fmt_uint and fmt_ulong you may use the _GENERIC makro fmt_dnum. yes, it says makro β we move π
π RETURN CODES π
If dest equals FMT_LEN (i.e. is zero), all fmt_* routins return the number of bytes it would have written i.e. the number of leading nonzero bytes of source perhaps including a \0. thatβs the whole return-code vibe, bestie β¨
π¦ SEE ALSO π¦
β¨ cute sign-off: this was the qlibs:(fmt) page, footer says 3 and qlibs:(fmt), and thereβs no date printed down there β so consider this your official group-chat goodbye. stay slay, may your buffers behave, and hydrate before touching pointers π
π«Άπ
π¦ where this page comes from
- alpine 3.24: fehqlibs-doc 31-r0 Β· Public-Domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms