ArticleslgStudy

science

Uuencoding

Uuencoding is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Uuencoding rather than just read about it. In short: uuencoding is a form of binary-to-text encoding that originated in the Unix programs uuencode and uudecode written by Mary Ann Horton at the University of California, Berkeley in 1980, for encoding binary data for transmission in email systems. The name "uuencoding" is derived from Unix-to-Unix Copy, i.e. "Unix-to-Unix encoding" is a safe encoding for the transfer of arbitrary files from one Unix system to another U…

Key takeaways

  • Uuencoding belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Uuencoding to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Uuencoding from memory before moving on to harder problems.

Reference excerpt

uuencoding is a form of binary-to-text encoding that originated in the Unix programs uuencode and uudecode written by Mary Ann Horton at the University of California, Berkeley in 1980, for encoding binary data for transmission in email systems. The name "uuencoding" is derived from Unix-to-Unix Copy, i.e. "Unix-to-Unix encoding" is a safe encoding for the transfer of arbitrary files from one Unix system to another Unix system but without guarantee that the intervening links would all be Unix systems. Since an email message might be forwarded through or to computers with different character sets or through transports which are not 8-bit clean, or handled by programs that are not 8-bit clean, forwarding a binary file via email might cause it to be corrupted. By encoding such data into a character subset common to most character sets, the encoded form of such data files was unlikely to be "translated" or corrupted, and would thus arrive intact and unchanged at the destination. The program uudecode reverses the effect of uuencode, recreating the original binary file exactly. uuencode/decode became popular for sending binary (and especially compressed) files by email and posting to Usenet newsgroups, etc. It has now been largely replaced by MIME and yEnc. With MIME, files that might have been uuencoded are instead transferred with Base64 encoding.

Encoded format A uuencoded file starts with a header line of the form:

begin <mode> <file><newline>

<mode> is the file's Unix file permissions as three octal digits (e.g. 644, 744). This is typically only significant to Unix-like operating systems. <file> is the file name to be used when recreating the binary data. <newline> signifies a newline character, used to terminate each line. Each data line uses the format:

<length character><formatted characters><newline>

<length character> is a character indicating the number of data bytes which have been encoded on that line. This is an ASCII character determined by adding 32 to the actual byte count, with the sole exception of a grave accent "`" (ASCII code 96) signifying zero bytes. All data lines, except the last (if the data length was not divisible by 45), have 45 bytes of encoded data (60 characters after encoding). Therefore, the vast majority of length values are 'M', (32 + 45 = ASCII code 77 or "M"). <formatted characters> are encoded characters. See § Formatting mechanism for more details on the actual implementation. The file ends with two lines:

`<newline> end<newline>

The second to last line is also a character indicating the line length, with the grave accent signifying zero bytes. As a complete file, the uuencoded output for a plain text file named cat.txt containing only the characters Cat would be

begin 644 cat.txt #0V%T ` end

The begin line is a standard uuencode header; the '#' indicates that its line encodes three characters; the last two lines appear at the end of all uuencoded files.

Formatting mechanism The mechanism of uuencoding repeats the following for every 3 bytes, encoding them into 4 printable characters, each character representing a radix-64 numerical digit:

Start with 3 bytes from the source, 24 bits in total. Split into 4 6-bit groupings, each representing a value in the range 0 to 63: bits (00-05), (06-11), (12-17) and (18-23). Add 32 to each of the values. With the addition of 32 this means that the possible results can be between 32 (" " space) and 95 ("_" underline). 96 ("`" grave accent) as the "special character" is a logical extension of this range. Despite space character being documented as the encoding for value of 0, implementations, such as GNU sharutils, actually use the grave accent character to encode zeros in the body of the file as well, never using space. Output the ASCII equivalent of these numbers. If the source length is not divisible by 3, then the last 4-byte section will contain padding bytes to make it cleanly divisible. These bytes are subtracted from the line's <length character> so that the decoder does not append unwanted characters to the file. uudecoding is reverse of the above, subtract 32 from each character's ASCII code (modulo 64 to account for the grave accent usage) to get a 6-bit value, concatenate 4 6-bit groups to get 24 bits, then output 3 bytes. The encoding process is demonstrated by this table, which shows the derivation of the above encoding for "Cat".

uuencode table The following table shows the conversion of the decimal value of the 6-bit fields obtained during the conversion process and their corresponding ASCII character output code and character. Note that some encoders might produce space (code 32) instead of grave accent ("`", code 96), while some decoders might refuse to decode data containing space.

Example The following is an example of uuencoding a one-line text file. In this example, %0D is the byte representation for carriage return, and %0A is the byte representation for line feed.

file File Name = wikipedia-url.txt File Contents = http://www.wikipedia.org%0D%0A

uuencoding begin 644 wikipedia-url.txt ::'1T<#HO+W=W=RYW:6MI<&5D:6$N;W)G#0H` ` end

Forks (file, resource) Unix traditionally has a single fork where file data is stored. However, some file systems support multiple forks associated with a single file. For example, classic Mac OS Hierarchical File System (HFS) supported a data fork and a resource fork. Mac OS HFS+ supports multiple forks, as does Microsoft Windows NTFS alternate data streams. Most uucoding tools will only handle data from the primary data fork, which can result in a loss of information when encoding/decoding (for example, Windows NTFS file comments are kept in a different fork). Some tools (like the classic Mac OS application UUTool) solved the problem by concatenating the different forks into one file and differentiating them by file name.

Relation to xxencode, Base64, and Ascii85

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Uuencoding

Start with the simplest possible case. Write down what Uuencoding claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Uuencoding before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Uuencoding ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Uuencoding

In research
Uuencoding appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Uuencoding in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Uuencoding is common in secondary-school and first-year university syllabi. It links to neighbouring topics Binary-to-text encoding formats, Email, Unix SUS2008 utilities, so understanding it makes those chapters shorter.
In everyday life
Look for Uuencoding outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Uuencoding” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Uuencoding in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Uuencoding means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Uuencoding out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Uuencoding in simple terms?

uuencoding is a form of binary-to-text encoding that originated in the Unix programs uuencode and uudecode written by Mary Ann Horton at the University of California, Berkeley in 1980, for encoding binary data for transmission in email systems. The name "uuencoding" is derived from Unix-to-Unix Cop…

Why does Uuencoding matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Uuencoding?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Uuencoding.

Tags

  • Binary-to-text encoding formats
  • Email
  • Unix SUS2008 utilities
  • Usenet

Keep exploring