Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Internet Protocols Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

10.3 Transfer Encodings

The Content-Transfer-Encoding of a MIME part describes how the data within the part body has been processed for transport (see Section 10.1.3). This section describes each encoding in detail.

10.3.1 Identity Encodings

The 7bit, 8bit, and binary encoding values state that the body of the message hasn't been encoded. In principle, there's no need to process unencoded data at all. For convenience, the encode() and decode() functions of RWMimeUtils accept the values "7bit", "8bit", and "binary" as encoding types. When any of these three values is provided as an encoding type, both functions simply return the original string.

Because unencoded values do not change the string provided, programs can safely call encode() and decode() with any MIME C-ontent-Transfer-Encoding value and receive the correct data.

10.3.2 Base 64 Encoding

Base 64 encoding, described in detail in RFC 2045, provides a simple way to translate binary data into an ASCII format suitable for use with the SMTP protocol. The encoding process generates four characters of encoded data for each three bytes of original data.

A base 64 encoder reads the byte sequence of the original data six bits at a time. Each six-bit value is encoded as one of 64 printable characters. After encoding, the encoder arranges the printable output in lines of 72 characters each. The result is a message that any RFC 822-compliant mail system can process without loss of data.

RWMimeUtils provides static utility functions, including a base 64 encoder. To encode data in base 64 format, use the encode() function with RWMimeUtils::Base64 as the second argument, for example:

Likewise, to decode base 64 encoded data, use the decode() function from RWMimeUtils, as shown:

10.3.3 Quoted-Printable Encoding

Quoted-printable encoding, described in detail in RFC 2045, provides a simple way to convert text into a format that is safe for delivery through SMTP applications. The encoding preserves many human readable characters, providing a way to encode messages that are primarily text. A message encoded in quoted-printable encoding consists entirely of 7-bit ASCII characters arranged in lines no more than 76 characters long.

A quoted-printable encoder escapes characters outside of the normal ASCII character set, non-printing characters, and some whitespace characters. Some other characters (notably punctuation marks) may also be escaped to ensure accurate transmission by non-ASCII systems. Line breaks, however, are not encoded. Therefore, quoted-printable encoding is only useful for text. Since the encoding does not protect a message against line-break translation during transmission, quoted-printable encoding cannot guarantee accurate delivery of binary data.

The format of a quoted-printable message is simple. The encoder converts any character that must be escaped to an equal sign (=) followed by the character's ASCII value in hexadecimal. For example, a VT character (ASCII value 11) is represented as =0B and a DEL character (ASCII value 127) is represented as =7F. If a TAB or SPACE character falls at the end of a line, a soft line break (=, ASCII 10, ASCII 13) is added after the TAB or SPACE. Once the entire message is escaped, the encoder adds line breaks so that no line of the message is longer than 76 characters. Each line break the encoder adds is preceded by a single = character.

RWMimeUtils provides static utility functions, including a quoted-printable encoder. To encode data in quoted-printable format, use encode() function with RWMimeUtils::QuotedPrintable as the second argument, for example:

Likewise, to decode quoted-printable encoded data, use the decode() function from RWMimeUtils, as shown:



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.