A64L(3P)

πŸ’– A64L(3P) β€” the POSIX Programmer's Manual one πŸ’–

okay bestie, welcome to a64l and l64a, straight out of the POSIX Programmer's Manual, section 3P. it's giving ✨radix-64✨ and it's honestly iconic.


🌸 PROLOG 🌸

okay so first things first, tiny little disclaimer, don't shoot the messenger: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ (so like, go consult the corresponding Linux manual page for details on Linux behavior), or β€” and this is the chaotic part β€” the interface may not even be implemented on Linux. πŸ’€


πŸŽ€ NAME πŸŽ€

a64l, l64a β€” convert between a 32-bit integer and a radix-64 ASCII string. that's the whole vibe. number goes in, string comes out, string goes in, number comes out. πŸ¦‹


✨ SYNOPSIS ✨

#include <stdlib.h>

long a64l(const char *s);
char *l64a(long value);

πŸ’… DESCRIPTION πŸ’…

so these functions maintain numbers stored in radix-64 ASCII characters. it's a whole notation where 32-bit integers can be represented by up to six characters, and each character is a digit in radix-64 notation. cute, right? but listen β€” if the type long contains more than 32 bits, only the low-order 32 bits shall be used for these operations. lowkey only the bottom 32 bits get to participate. 🫢

the characters used to represent digits are, and I need you to memorize this because it's not the alphabet you're expecting:

  • '.' (dot) for 0
  • '/' for 1
  • '0' through '9' for [2,11]
  • 'A' through 'Z' for [12,37]
  • 'a' through 'z' for [38,63]

the a64l() function shall take a pointer to a radix-64 representation, in which the first digit is the least significant, and return the corresponding long value. yeah. least significant digit on the LEFT. it's backwards from what your brain wants and that's just the way it is. πŸŒ€

if the string pointed to by s contains more than six characters, a64l() shall use the first six. if the first six characters of the string contain a null terminator, a64l() shall use only characters preceding the null terminator. and then: the a64l() function shall scan the character string from left to right with the least significant digit on the left, decoding each character as a 6-bit radix-64 number. if the type long contains more than 32 bits, the resulting value is sign-extended. periodt.

🚨 the behavior of a64l() is unspecified if s is a null pointer, or if the string pointed to by s was not generated by a previous call to l64a(). so don't be out here feeding it random strings and acting surprised. πŸ™ˆ

the l64a() function shall take a long argument and return a pointer to the corresponding radix-64 representation.

🚨 the behavior of l64a() is unspecified if value is negative. negative numbers? not the move. absolutely not the move.

also, important, and I mean this with love: the value returned by l64a() may be a pointer into a static buffer. subsequent calls to l64a() may overwrite the buffer. so if you're holding onto that pointer like it's your emotional support string, it's gonna get rewritten out from under you. 😭

and the l64a() function need not be thread-safe. no cap. 🧚


πŸ”₯ RETURN VALUE πŸ”₯

upon successful completion, a64l() shall return the long value resulting from conversion of the input string. and if the string pointed to by s is an empty string, a64l() shall return 0L. slay.

the l64a() function shall return a pointer to the radix-64 representation. and if value is 0L, l64a() shall return a pointer to an empty string. πŸ‘‘


πŸ’€ ERRORS πŸ’€

no errors are defined. none. zero. the girls are simply not erroring today. ✨

the following sections are informative. (yes, that's literally what it says, so like, heads up that the fun parts are advisory-flavored.)


🌈 EXAMPLES 🌈

None.

i know. i know. tragic. no examples for us. we're on our own out here. πŸ˜”


πŸ“ APPLICATION USAGE πŸ“

if the type long contains more than 32 bits, the result of a64l(l64a(x)) is x in the low-order 32 bits. so like, round-trip works β€” but only down there in the low 32. the top bits are just vibes. πŸ’œ


⭐ RATIONALE ⭐

this is not the same encoding as used by either encoding variant of the uuencode utility. i need you to hear me on this one. do not mix them up. they are cousins at best, not twins. βœ‹


πŸ¦‹ FUTURE DIRECTIONS πŸ¦‹

None.

the future is empty. the future is now. πŸ’…


πŸ‘‘ SEE ALSO πŸ‘‘

  • strtoul()
  • The Base Definitions volume of POSIX.1‐2017, <stdlib.h>
  • The Shell and Utilities volume of POSIX.1‐2017, uuencode

okay legal bestie moment, I need to be so for real with you, this part matters:

portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page, babe. brought to you by IEEE/The Open Group, 2017 β€” mwah, love that for them πŸ’– stay radix-64, stay six characters max, and never forget that the first digit is the least significant. iykyk. πŸŽ€βœ¨

πŸ“¦ where this page comes from