SMSLEN(1)

๐Ÿ“ฆ version 1.2.2, in opensuse-leap 16.0

๐Ÿ’Œ smslen(1): the smol guide to SMS payload math ๐Ÿ’…

okay so bestie, welcome to smslen โ€” a Gen Z safe space for Calculate SMS message payload length. yes that's the whole name section, slay โœจ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

like, three ways to run this icon:

smslen [-i encoding] [filename]

smslen -r limit [-i encoding] [filename]

smslen -t limit [-i encoding] [filename]

๐Ÿ’– DESCRIPTION ๐Ÿ’–

smslen crunches the numbers on how many bytes of SMS payload your input text is gonna eat up. it's giving calculator but make it text. ๐Ÿงฎโœจ

here's the algorithm's whole personality: first it tries to encode the input with GSM 03.38, which needs seven or 14 bits per character โ€” the 14 is for the ``extension'' characters, fyi, they're extra like that. but plot twist ๐Ÿ˜ญ only certain commonly-used characters are even encodable in GSM 03.38, so the moment it spots even ONE unsupported character, it gives up and reverts to UTF-16 encoding for the entire message โ€” the whole thing, no partial situation โ€” which means 16 bits per character. no cap, one weird character and the whole vibe shifts. ๐Ÿ’€

the first form just prints the number of bytes required to encode the input. that's it, that's the tea.

the -r form is the same math but flipped, lowkey inverted โ€” it prints the number of input bytes that will fit under the given encoded length limit. and because the SMS payload limit is 140 bytes, running -r 140 tells you exactly how much of your input fits in a single SMS message. iconic for when you're texting someone and gotta know if it's one bubble or two. ๐Ÿซถ

the -t form does the same calculation as the -r form but actually copies the input to the output, truncating it the moment the calculated limit number of encoded output bytes is reached. so it's like -r but it hands you the actual trimmed text instead of a number. she does both, she's versatile. ๐Ÿ‘‘


โœจ OPTIONS โœจ

  • -i โ€” specify the input character encoding. bestie, by default UTF-8 is assumed, so you only need this if you're being spicy.
  • -r limit โ€” output the number of input bytes that, when encoded into an SMS payload, will have a length at most limit. (math, but make it fashion ๐Ÿ’…)
  • -t limit โ€” copy the input to the output right up until the encoded length would reach limit. truncation station, next stop: your screen ๐Ÿš‚
  • -h โ€” output the usage message and exit. the classic "what does this even do" button, we love her.

๐ŸŒˆ EXIT STATUS ๐ŸŒˆ

smslen exits zero normally โ€” good vibes, no notes. but it'll exit 1 if an error occurs. ๐Ÿ˜ญ

possible errors include an invalid byte sequence in the input. so if you feed it garbage bytes, don't be surprised when it's like "nope" and bails. ๐Ÿšฉ

fr fr, garbage in = exit code 1 out. be careful what you pipe into her.

๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

the whole friend group: twimsg(1), twils(1), twirm(1), twiping(1), twilog(1). squad goals. ๐Ÿซถ

also the reading list, because she's well-read:

the links are literally copied character for character, go read them, iykyk. ๐Ÿ“š

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Archie L. Cobbs <archie.cobbs@gmail.com> โ€” the main character who wrote this. respect the icon. ๐ŸŽ€



๐Ÿ’– and that's the whole page, bestie ๐Ÿ’–

this little love letter to the manpage universe was brought to you by Debian, dated May 17, 2013 โ€” vintage, retro, still slaying. mwah ๐Ÿ’‹๐ŸŒธ

๐Ÿ“ฆ where this page comes from