Skip to content

Add the 'u' (uuencode) pack/unpack directive - #446

Merged
tannevaled merged 1 commit into
mainfrom
feat/cluster18
Aug 25, 2026
Merged

tannevaled merged 1 commit into
mainfrom
feat/cluster18

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Array#pack("u") and String#unpack("u") raised unknown directive 'u'. They
now implement uuencoding and uudecoding:

  • pack("u") emits one line per chunk: a length character (data-byte count),
    then the bytes in groups of three as four 6-bit characters (value 0 as a
    backtick, others as value+0x20), then a newline. The count modifier sets the
    bytes-per-line — *, 0, 1, 2, or none means 45; otherwise it is rounded
    down to a multiple of three. An empty input yields an empty string, a
    non-String element raises TypeError, and the result is US-ASCII.
  • unpack("u") decodes the whole input across newline-separated lines back to a
    single BINARY string, ignoring the count/* modifier; each character
    contributes (c-0x20)&0x3f and a CR?LF terminates a line. Decoding stops at
    the first character that cannot begin a line.

Verified against ruby 4.0.6. Full package coverage stays at 100.0%.
Zero-regression rubyspec sweep; core/array/pack/u_spec 17 → 35 and
core/string/unpack/u_spec 17 → 25 (the remaining failures in both files are
pre-existing U-directive and shared-mock issues, unrelated to u). Two shared
examples in pack/a_spec and pack/z_spec also start passing now that u is a
recognized directive.

🤖 Generated with Claude Code

Array#pack("u") and String#unpack("u") raised "unknown directive 'u'". They now
implement uuencoding and uudecoding:

  - pack("u") emits one line per chunk: a length character (data-byte count),
    then the bytes in groups of three as four 6-bit characters (value 0 as a
    backtick, others as value+0x20), then a newline. The count modifier sets the
    bytes-per-line — '*', 0, 1, 2, or none means 45; otherwise it is rounded
    down to a multiple of three. An empty input yields an empty string, a
    non-String element raises TypeError, and the result is US-ASCII.
  - unpack("u") decodes the whole input across newline-separated lines back to a
    single BINARY string, ignoring the count/'*' modifier; each character
    contributes (c-0x20)&0x3f and a CR?LF terminates a line. Decoding stops at
    the first character that cannot begin a line.

Verified against ruby 4.0.6. Full package coverage stays at 100.0%. Zero-
regression rubyspec sweep; core/array/pack/u_spec 17 -> 35 and
core/string/unpack/u_spec 17 -> 25 (with the remaining failures in both files
being pre-existing 'U'-directive and shared-mock issues, unrelated to 'u'). Two
shared examples in pack/a_spec and pack/z_spec also start passing now that 'u'
is a recognized directive.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 49598df into main Aug 25, 2026
7 checks passed
@tannevaled
tannevaled deleted the feat/cluster18 branch August 25, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant