Uuencoding

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,[1] 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:

  1. Start with 3 bytes from the source, 24 bits in total.
  2. 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).
  3. 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,[2] actually use the grave accent character to encode zeros in the body of the file as well, never using space.
  4. 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".

Original characters C a t
Original ASCII, decimal 67 97 116
ASCII, binary 0 1 0 0 0 0 1 1 0 1 1 0 0 0 0 1 0 1 1 1 0 1 0 0
New decimal values 16 54 5 52
+32 48 86 37 84
Uuencoded characters 0 V % T

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.

bits ASCII
code
ASCII
char
bits ASCII
code
ASCII
char
bits ASCII
code
ASCII
char
bits ASCII
code
ASCII
char
00 96 ` 16 48 0 32 64 @ 48 80 P
01 33 ! 17 49 1 33 65 A 49 81 Q
02 34 " 18 50 2 34 66 B 50 82 R
03 35 # 19 51 3 35 67 C 51 83 S
04 36 $ 20 52 4 36 68 D 52 84 T
05 37 % 21 53 5 37 69 E 53 85 U
06 38 & 22 54 6 38 70 F 54 86 V
07 39 ' 23 55 7 39 71 G 55 87 W
08 40 ( 24 56 8 40 72 H 56 88 X
09 41 ) 25 57 9 41 73 I 57 89 Y
10 42 * 26 58 : 42 74 J 58 90 Z
11 43 + 27 59 ; 43 75 K 59 91 [
12 44 , 28 60 < 44 76 L 60 92 \
13 45 - 29 61 = 45 77 M 61 93 ]
14 46 . 30 62 > 46 78 N 62 94 ^
15 47 / 31 63 ? 47 79 O 63 95 _

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

Despite its limited range of characters, uuencoded data is sometimes corrupted on passage through certain computers using non-ASCII character sets such as EBCDIC. One attempt to solve the problem was the xxencode format, which used only alphanumeric characters and the plus and minus symbols. More common today is the Base64 format, which is based on the same concept of alphanumeric-only as opposed to ASCII 32–95. All three formats use 6 bits (64 different characters) to represent their input data.

Base64 can also be generated by the uuencode program and is similar in format, except for the actual character translation:

The header is changed to

begin-base64 <mode> <file>

the trailer becomes

====

and lines between are encoded with characters chosen from

ABCDEFGHIJKLMNOP
QRSTUVWXYZabcdef
ghijklmnopqrstuv
wxyz0123456789+/

Another alternative is Ascii85, which encodes four binary characters in five ASCII characters. Ascii85 is used in PostScript and PDF formats.

Disadvantages

uuencoding takes 3 pre-formatted bytes and turns them into 4 and also adds begin/end tags, filename, and delimiters. This adds at least 33% data overhead compared to the source alone, though this can be at least somewhat compensated for by compressing the file before uuencoding it.

Support in languages

Python

The Python language supports uuencoding using the codecs module with the codec "uu":

For Python 2 (deprecated/sunset as of January 1st 2020):

$ python -c 'print "Cat".encode("uu")'
begin 666 <data>
#0V%T

end

$

For Python 3 where the codecs module needs to be imported and used directly:

$ python3 -c "from codecs import encode;print(encode(b'Cat', 'uu'))"
b'begin 666 <data>\n#0V%T\n \nend\n'
$

To decode, pass the whole file:

$ python3 -c "from codecs import decode;print(decode(b'begin 666 <data>\n#0V%T\n \nend\n', 'uu'))"
b'Cat'

Perl

The Perl language supports uuencoding natively using the pack() and unpack() operators with the format string "u":

$ perl -e 'print pack("u","Cat")'
#0V%T

Decoding base64 with unpack can likewise be accomplished by translating the characters:

$ perl -e 'print unpack("u","#0V%T")'
Cat

To produce wellformed uuencoded files, you need to use modules,[3] or a little bit more of code:[4]

Encode (oneliner)

$ perl -ple  'BEGIN{use File::Basename;$/=undef;$sn=basename($ARGV[0]);} $_= "begin 600 $sn\n".(pack "u", $_)."`\nend" if $_' /some/file/to_encode.gz

Encode/Decode (proper Perl scripts)

https://metacpan.org/dist/PerlPowerTools/view/bin/uuencode

https://metacpan.org/dist/PerlPowerTools/view/bin/uudecode

See also

References

  1. ^ Horton, Mark. "UUENCODE(1C) UNIX Programmer's Manual". The Unix Heritage Society. Retrieved 2020-11-10.
  2. ^ "uuencode.c source". fossies.org. Retrieved 2021-06-05.
  3. ^ "PerlPowerTools source". metacpan.org. Retrieved 2024-02-12.
  4. ^ "uuencode.pl source". main.linuxfocus.org. Retrieved 2024-02-12.
  • uuencode entry in POSIX.1-2008
  • GNU-sharutils – open source suite of shar/unshar/uuencode/uudecode utilities
  • UUDeview – open-source program to encode/decode Base64, BinHex, uuencode, xxencode, etc. for Unix/Windows/DOS
  • UUENCODE-UUDECODE – open-source program to encode/decode created by Clem "Grandad" Dye
  • StUU – open source fast UUDecoder for Macintosh by Stuart Cheshire
  • UUENCODE-UUDECODE – free on-line UUEncoder and UUDecoder
  • Java UUDecoder – open source Java library for decoding uuencoded (mail) attachments
  • AN11229 – NXP application note: UUencoding for UART ISP


Read other articles:

United States historic placeElizabeth Bard Memorial HospitalU.S. National Register of Historic Places Bard Memorial, April 2018Location121 N. Fir St., Ventura, CaliforniaCoordinates34°16′56″N 119°17′18″W / 34.28222°N 119.28833°W / 34.28222; -119.28833Built1902ArchitectSelwyn Lock ShawArchitectural styleMission/Spanish RevivalNRHP reference No.77000361Added to NRHPNovember 11, 1977[1] Elizabeth Bard Memorial Hospital, now known as The ...

 

 

Artikel atau sebagian dari artikel ini mungkin diterjemahkan dari Predation di en.wikipedia.org. Isinya masih belum akurat, karena bagian yang diterjemahkan masih perlu diperhalus dan disempurnakan. Jika Anda menguasai bahasa aslinya, harap pertimbangkan untuk menelusuri referensinya dan menyempurnakan terjemahan ini. Anda juga dapat ikut bergotong royong pada ProyekWiki Perbaikan Terjemahan. (Pesan ini dapat dihapus jika terjemahan dirasa sudah cukup tepat. Lihat pula: panduan penerjemahan a...

 

 

Anti-arrhythmic medication This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Propafenone – news · newspapers · books · scholar · JSTOR (May 2019) (Learn how and when to remove this template message) PropafenoneClinical dataPronunciation/proʊˈpæfɪnoʊn/ proh-PAF-i-nohn Trade namesRythmol, Rytmonorm, ot...

RobertmoorePenemuanDitemukan olehNEATSitus penemuanHaleakalaTanggal penemuan8 September 2002PenamaanPenamaan MPC84200Penamaan alternatif2002 RM122Ciri-ciri orbitEpos 14 Mei 2008Aphelion3.4570094Perihelion2.9637142Eksentrisitas0.0768286Periode orbit2101.0161565Anomali rata-rata234.79424Inklinasi7.95199Bujur node menaik97.14838Argumen perihelion26.40661Ciri-ciri fisikMagnitudo mutlak (H)14.6 84200 Robertmoore (2002 RM122) adalah sebuah asteroid yang terletak di sab...

 

 

Questa voce sull'argomento calciatori brasiliani è solo un abbozzo. Contribuisci a migliorarla secondo le convenzioni di Wikipedia. Segui i suggerimenti del progetto di riferimento. João Figueiredo Nazionalità  Brasile Calcio Ruolo Attaccante Squadra  İstanbul Başakşehir Carriera Squadre di club1 2016 Atlético Mineiro3 (0)2017→  Democrata-GV0 (0)[1]2018-2019 Kauno Žalgiris39 (14)2019-2020 OFI Creta34 (11)2020-2021 Al-Wasl23 (10)2021-2...

 

 

Women's épéeat the Games of the XXVIII OlympiadVenueHelliniko Olympic ComplexDateAugust 15← 20002008 → Fencing at the2004 Summer OlympicsÉpéemenwomenTeam épéemenwomenFoilmenwomenTeam foilmenSabremenwomenTeam sabremenvte These are the results of the women's épée competition in fencing at the 2004 Summer Olympics in Athens. A total of 39 women competed in this event. Competition took place in the Fencing Hall at the Helliniko Olympic Complex on August 15. Tournamen...

Disambiguazione – Se stai cercando altri significati, vedi Villa Borghese (disambigua). Villa BorgheseL'ingresso monumentale su piazzale Flaminio UbicazioneStato Italia LocalitàRoma CaratteristicheTipoVilla, parco storico[1] Superficie80 ettari Inaugurazione1903 GestoreRoma Capitale AperturaTutti i giorni dall'alba al tramonto Ingressiv. U. Aldrovandiv. A. Raimondi(2 ingressi)v. di Porta Pinciana (2 ingressi)P.le S. Paolo del Brasilep.le Flaminiop.le Cervantesp.le P. Picasso(...

 

 

Stonehenge, situs prasejarah yang hingga kini masih menjadi kajian arkeoastronomi. Matahari terbit akan menerangi ruang dalam Newgrange, Irlandia, hanya pada saat titik balik matahari musim dingin. Matahari terbenam di ekuinoks dilihat dari situs prasejarah Pizzo Vento di Fondachelli Fantina, Sisilia Bagian dari seriIlmu Pengetahuan Formal Logika Matematika Logika matematika Statistika matematika Ilmu komputer teoretis Teori permainan Teori keputusan Ilmu aktuaria Teori informasi Teori sistem...

 

 

Кораклы на реке Тайви, западный Уэльс, 1972 год[1] Коракл (валл. cwrwgl, англ. Coracle) — небольшая традиционная лодка, используемая в основном на реках Уэльса, но также местами в западной и юго-западной Англии, Ирландии (особенно на реке Бойн[2]) и Шотландии (особенно �...

Voce principale: Bologna Football Club 1909. Bologna AGCStagione 1940-1941 Sport calcio Squadra Bologna Allenatore Hermann Felsner Presidente Renato Dall'Ara Serie A1º Coppa ItaliaQuarti di finale Maggiori presenzeCampionato: Biavati, Reguzzoni (30)Totale: Biavati (34) Miglior marcatoreCampionato: Puricelli (22)Totale: Puricelli (28) StadioLittoriale 1939-1940 1941-1942 Dati aggiornati al 25 maggio 1941Si invita a seguire il modello di voce Questa voce raccoglie le informazioni rig...

 

 

1986 soundtrack album by Herbie HancockRound MidnightSoundtrack album by Herbie HancockReleased1986RecordedJuly 1–12 and August 20–23, 1985StudioLive at Studio Eclair, Epinay Sur Seine, France, Studio Phillipe Sarde, Paris, FranceGenreJazz, hard bopLabelColumbia 40464ProducerHerbie HancockHerbie Hancock chronology Village Life(1985) Round Midnight(1986) Jazz Africa(1987) Dexter Gordon chronology American Classic(1982) Round Midnight(1986) The Other Side of Round Midnight(1986) Pro...

 

 

Untuk tempat lain yang bernama sama, lihat Ngantru (disambiguasi). NgantruKecamatanPeta lokasi Kecamatan NgantruNegara IndonesiaProvinsiJawa TimurKabupatenTulungagungPemerintahan • Camat-Populasi • Total- jiwaKode Kemendagri35.04.04 Kode BPS3504140 Luas- km²Desa/kelurahan13 desa Ngantru adalah sebuah kecamatan di Kabupaten Tulungagung, Jawa Timur, Indonesia. Ngantru terletak di ujung utara kota Tulungagung, dan berbatasan langsung dengan Kabupaten Kediri di sebel...

Bed designed for hospital patients A modern hospital bed at public hospital at Hong Kong Hospital beds per 1000 people 2013.[1] A hospital bed or hospital cot is a bed specially designed for hospitalized patients or others in need of some form of health care. These beds have special features both for the comfort and well-being of the patient and for the convenience of health care workers. Common features include adjustable height for the entire bed, the head, and the feet, adjustable ...

 

 

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (نوفمبر 2018) منظمة مساعدة المرأةالتاريخالتأسيس 1982 الإطارالنوع منظمة غير حكومية التنظيمموقع الويب wao.org.my تعديل - تعديل مصدري - تعديل ويكي بيانات منظمة مساعدة المرأة هي م�...

 

 

Fungible item produced to satisfy wants or needs For other uses, see Commodity (disambiguation). Yerba mate (left), coffee bean (middle) and tea (right), all used for caffeinated infusions, are commodity cash crops.Business administration Management of a business Accounting Management accounting Financial accounting Audit Business entity (list) Corporate group Corporation sole Conglomerate (company) Holding company Cooperative Corporation Joint-stock company Limited liability company Partners...

Pemilihan umum Wali Kota Makassar 20182013202027 Juni 2018Terdaftar1.021.714Kehadiran pemilih584.406Kandidat   Calon Kolom kosong Munafri Arifuddin Partai Golkar Pendamping Rachmatika Dewi Suara rakyat 300.795 264.245 Persentase 53,23% 46,77% Peta persebaran suara Letak Kota Makassar di Provinsi Sulawesi Selatan Wali Kota petahanaDanny Pomanto Demokrat Wali Kota terpilih Tidak ada Pemilihan Umum Wali Kota Makassar 2018 (selanjutnya disebut Pilwako Makassar 2018 atau Pilwalkot Makas...

 

 

Guinean Nationality LawNational Assembly of Guinea Long title Code civil de la Republique de Guinée — Titre IV: de la nationalité, Articles 50–179 Enacted byGovernment of GuineaAssented to5 October 2019Status: Current legislation Guinean nationality law is regulated by the Constitution of Guinea, as amended; the Guinean Nationality Code, and its revisions; the Civil Code of Guinea; the Family Code of Guinea; and various international agreements to which the country is a signa...

 

 

Wahana penjelajah Mars merupakan sebuah wahana antariksa tak berawak yang ditujukan untuk menjelajahi Mars. Wahana penjelajah yang pertama, disebut Sojourner, diluncurkan oleh NASA pada tanggal 4 Desember 1996 dan berhasil mendarat di Mars pada tanggal 4 Juli 1997. NASA menggunakan rancangan baru dan besar untuk 2 misi berikutnya: Spirit (diluncurkan pada tanggal 10 Juni 2003 pada pukul 1:59 p.m. EDT) dan Opportunity (diluncurkan pada tanggal 7 Juli 2003 pada pukul 11:18 p.m. EDT). Wahana pen...

Economic, political, and judicial institution during the Middle Ages in Europe This article is about the medieval system. For the 17th-century system in Canada, see Seigneurial system of New France. This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Manorialism – news · newspapers · books · scholar · JSTOR (Dec...

 

 

American businesswoman and politician Martha Layne CollinsCollins in the early 1980s56th Governor of KentuckyIn officeDecember 13, 1983 – December 8, 1987LieutenantSteve BeshearPreceded byJohn Y. Brown Jr.Succeeded byWallace Wilkinson48th Lieutenant Governor of KentuckyIn officeDecember 11, 1979 – December 13, 1983GovernorJohn Y. Brown Jr.Preceded byThelma StovallSucceeded bySteve Beshear Personal detailsBornMartha Layne Hall (1936-12-07) December 7, 1936 (age 87)Ba...