ascii2binary(1)

πŸ’– ascii2binary(1) β€” like, the whole entire manual, but make it make sense πŸ’–

okay bestie, welcome to the General Commands Manual page for ascii2binary, except now it's in a voice you'll actually read. grab a boba, we're converting text numbers into raw bytes and it's gonna be iconic. ✨


🌸 NAME 🌸

ascii2binary β€” converts ASCII numbers into binary. that's it. that's the job. she takes your cute little typed-out digits and turns them into actual bytes. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

ascii2binary [flags]

no file arguments, no positional anything. it's all about the flags, babe. πŸ’–


✨ DESCRIPTION ✨

so here's the vibe: ascii2binary reads input made of a whole sequence of ASCII textual representations of numbers β€” like, actual human-typed digits β€” separated by whitespace, and spits out the binary equivalents on the other side. glow-up complete. πŸ¦‹

the type of the output (unsigned integer, signed integer, or floating point number) and its size are picked with command line flags. if you don't say anything, the default is unsigned character. yes, the tiniest little byte baby. πŸŽ€

and listen β€” input gets checked twice. once for format errors, and once to make sure the number you asked for can actually be represented in the binary type and size you requested. she does not let anything slide. periodt. πŸ’…


πŸ“ INPUT FORMAT πŸ“

the input formats supported are exactly the ones supported by strtod(3) for floating point numbers, by strtoll(3) for signed integers, and by strtoull(3) for unsigned integers β€” with one lil exception: unlike strtod(3), floating point numbers may have thousands separators. she's generous like that. πŸ’–

this means that, by default, integers may be decimal, octal, or hexadecimal, determined by the usual conventions. iykyk. 🌈

and the command line flag -b can be used to specify another base for integer conversions. slay. πŸ”₯


πŸ‘‘ COMMAND LINE FLAGS πŸ‘‘

lowkey important heads up: long options may not be available on some systems. 😭
  • -b,--base <base> β€” sets the base in the range [2,36] for integer conversions. and the base can be either an integer, or one of these cuties:
    • (b) binary
    • (o) octal
    • (d) decimal
    • (h) hexadecimal
  • -h,--help β€” prints the help message. your girl always explains herself. πŸ’…
  • -L,locale <locale> β€” sets the LC_NUMERIC facet of the locale to <locale>. (yes, that's exactly how it's written up there, don't come for me 🫢)
  • -s,--sizes β€” prints the sizes of the types on the current machine plus related information. a little vibe check of your hardware. πŸ¦‹
  • -t,--type <type> β€” sets the type and size of the output. the possible output types are listed below. note that some types may not be available on some machines. πŸ’€
    • d β€” double
    • f β€” float
    • sc β€” signed char
    • ss β€” signed short
    • si β€” signed int
    • sl β€” signed long
    • sq β€” signed long long
    • uc β€” unsigned char
    • us β€” unsigned short
    • ui β€” unsigned int
    • ul β€” unsigned long
    • uq β€” unsigned long long
  • -v,--version β€” identifies the version. main character announcement moment. πŸ‘‘
  • -X,--explain-exit-codes β€” prints a summary of the exit status codes. the receipts, basically. 🧾

πŸ’€ EXIT STATUS πŸ’€

these are the values returned on exit, bestie. memorize them, they're your love language now:

  1. 0 SUCCESS β€” the input was successfully converted. we ate. πŸ”₯
  2. 1 INFO β€” the user requested information such as the version number or usage synopsis, and this has been provided. you asked, she answered. 🫢
  3. 2 SYSTEM ERROR β€” an error resulted from a failure of the operating system, such as an i/o error or inability to allocate storage. not her fault, the OS is being messy. 😭
  4. 3 COMMAND LINE ERROR β€” the program was called with invalid or inconsistent command line flags. flags were flagging wrong. 🚩
  5. 4 RANGE ERROR β€” this means the input may be well-formed but cannot be represented as the required type. for example, if the input is the string 983 and ascii2binary is requested to convert this into an unsigned byte, ascii2binary will exit with a RANGE ERROR because 983 exceeds the maximum value representable in an unsigned byte, which is 255. she's too big for that container, respectfully. πŸ’…
  6. 5 INPUT ERROR β€” this means the input was ill-formed, that is, it could not be interpreted as a number of the required type. for example, if the input is 0x2A and a decimal value is called for, an INPUT ERROR will be returned since 0x2A is not a valid representation of a decimal integer. wrong era, wrong format. πŸ™ˆ

πŸŽ€ AUTHOR πŸŽ€

Bill Poser (billposer@alum.mit.edu) β€” the original genius behind all this. we stan. πŸ‘‘


🌈 LICENSE 🌈

GNU General Public License, version 3. open source royalty fr fr. πŸ’œ


πŸ’œ SEE ALSO πŸ’œ

binary2ascii(1), strtod(3), strtoll(3), strtoull(3) β€” go read those next, bestie, they're the whole friend group. 🫢


and that's the page!! ✨ written July, 2010 (so she's a vintage icon, an elder stateswoman of the manual pages πŸŽ€), living under the General Commands Manual banner like the queen she is. ok bye, go convert something πŸ’–πŸ¦‹πŸŒΈ