> unix | classic | legacy <
// UUencoding - Unix-to-Unix encoding for binary data transmission
Unix Standard
Traditional Unix encoding method used for decades in email and Usenet.
Wide Support
Supported by most Unix/Linux systems and email clients natively.
Self-Contained
Includes file permissions and name metadata in the encoded output.
>> technical info
How UUencoding Works:
UUencoding converts binary data into ASCII text using printable characters. It encodes 3 bytes into 4 characters, similar to Base64, but uses a different character set starting from space (ASCII 32).
Example:
"Hello" → begin 644 data\n%2&5L;&\\`\n`\nend
Why Use UUencoding:
- >Historic Unix/Linux standard
- >Preserves file permissions
- >Self-contained format
- >Email and Usenet compatible
- >Built into most Unix tools
>> frequently asked questions
What is UUencoding?
UUencoding (Unix-to-Unix encoding) is a binary-to-text encoding scheme that was widely used to transfer binary files over text-only communication channels like email and Usenet.
How does UUencoding differ from Base64?
While both encode 3 bytes into 4 characters, UUencoding uses a different character set starting from space (ASCII 32) and includes file metadata like permissions and filename in the encoded output.
When should I use UUencoding?
UUencoding is best for compatibility with legacy Unix/Linux systems, when you need to preserve file permissions, or when working with tools that specifically expect UUencoded format.
Is UUencoding still relevant?
While Base64 has largely replaced UUencoding for most purposes, UUencoding is still used in some Unix/Linux utilities and legacy systems where compatibility is important.
What does a UUencoded file actually look like?
A complete UUencoded payload has three parts: a begin header with mode and filename, body lines where each begins with a length character, and an end marker:
begin 644 hello.txt
%2&5L;&\`
`
end• Mode: Unix file permissions (644 = rw-r--r--).• Filename: the original file name.
• Body line: starts with
M (ASCII 77, meaning 45 bytes follow) or a smaller length character for the last line. Each character encodes 6 bits starting from (space) (0x20).• Final backtick (
`) means zero bytes — a clean end-of-data marker.Modern
uuencode -m emits Base64 inside a similar wrapper; classic uuencode uses the traditional space-based alphabet shown above.
How do I uuencode / uudecode on the command line?
Most Unix/Linux distributions ship uuencode and uudecode in the sharutils package (or coreutils on macOS via Homebrew):
Encode a file: uuencode hello.bin hello.bin > hello.uu
Decode: uudecode hello.uu — recreates hello.bin with the original permissions.
Pipe through email: uuencode file.zip file.zip | mail -s 'file' user@example.com — classic 1990s workflow.
Python: import uu; uu.encode('hello.bin', 'hello.uu') and uu.decode('hello.uu'). Note: Python's uu module is deprecated in 3.11+ and removed in 3.13 — use external tools for new code.
UUencode vs Base64 — which should I use today?
Almost always Base64. Comparison:
| UUencode | Base64 | |
|---|---|---|
| Overhead | ~35% | ~33% |
| Alphabet | ASCII 32-95 (includes space) | A-Z a-z 0-9 + / = |
| Line length | Fixed 45 bytes per line | Flexible (MIME = 76 chars) |
| Metadata | Filename + Unix mode | None (requires MIME headers) |
| Modern use | Legacy / retro | Universal (email, HTTP, JSON) |
Why does UUencode use space characters — isn't that risky in email?
Yes, that's UUencode's Achilles' heel. The original 1980s UUencode alphabet starts at ASCII 32 (space) and runs through ASCII 95 (_). Email systems that trim trailing whitespace or collapse multiple spaces can silently corrupt UUencoded payloads.
To work around this, many implementations translate space (0x20) to backtick (0x60) on encode, since backtick isn't trimmed. If you're decoding an old file and getting garbage, try running it through tr '\x60' '\x20' first.
This was one major reason Base64 (MIME, 1996) replaced UUencode in email — Base64 avoids all whitespace characters in its alphabet.
Can UUencode handle binary files with null bytes?
Yes — that's exactly what UUencode was designed for. The encoding transforms any byte sequence (0x00 through 0xFF) into printable 7-bit ASCII that survives email transport, Usenet posting, and BBS transfer. Null bytes (\x00) encode normally like any other byte — they don't terminate the stream. The begin/end markers and the line-length prefix handle framing, so binary content inside is fully transparent.