Hunny Software Library Reference

QuotedPrintableEncoder Class

Class that performs quoted-printable encoding.

For a list of all members of this type, see QuotedPrintableEncoder Members.

System.Object
   QuotedPrintableEncoder

[Visual Basic]
Public Class QuotedPrintableEncoder
[C#]
public class QuotedPrintableEncoder

Remarks

Quoted-printable encoding encodes 8-bit text into printable ASCII characters for sending through the Internet mail system. The encoding is required because 8-bit characters cannot pass reliably through the Internet mail system. In the quoted-printable encoding, a character that is not in the ASCII 7-bit character set is encoded as an equals sign (the character "=") followed by two hex digits (0-9 and A-F). Certain ASCII characters are also encoded. The quoted-printable encoding also encodes "soft" line breaks, since long lines also cannot pass reliably through the Internet mail system. The details of quoted-printable encoding can be found in RFC 2045.

QuotedPrintableEncoder provides two interfaces for performing quoted-printable encoding.

A high-level interface encodes from an input ByteString to an output ByteString. This interface comprises a single method, Encode().

A low-level interface allows encoding by passing multiple buffers to the encoder. The correct procedure for using this interface is described below.

QuotedPrintableEncoder allows you to change certain options, which affect the behavior of the encoder:

Using the Low-Level Interface

The low-level interface allows you to encode 8-bit text data one buffer at a time; thus you may encode text data of unlimited size using a limited amount of memory. For example, if you want to encode data from an input file to an output file, you may read from the input file one buffer at a time, pass each buffer to the encoder, and write to the output file one buffer at a time.

The low-level interface comprises three methods: Start(), EncodeSegment(), and Finish(). The procedure is described here:

  1. Call Start() to initialize the encoder.
  2. Initialize an input buffer and an output buffer. These buffers are instances of ByteBuffer. To initialize an input buffer named inBuf, set inBuf.Bytes to a byte array that contains the data to be encoded, set inBuf.Pos to the offset of the beginning of the data in inBuf.Bytes, and set inBuf.EndPos to the offset of the first byte past the end of the data in inBuf.Bytes. To initialize an output buffer named outBuf, set outBuf.Bytes to a byte array, set outBuf.Pos to zero, and set outBuf.EndPos to the length of the array referenced by outBuf.Bytes.
  3. Call EncodeSegment() with the input buffer and output buffer as arguments.
  4. Check to see if the output buffer is full or if the input buffer is empty. If outBuf.Pos == outBuf.EndPos, then the output buffer is full, and you must make room in the output buffer before you call EncodeSegment() again. If inBuf.Pos == inBuf.EndPos, then the input buffer is empty, and you must supply the input buffer with more data before you call EncodeSegment() again.
  5. Repeat steps 3 and 4 until the last input buffer is empty.
  6. Call Finish() to flush any internally buffered data to the output buffer. If the output buffer is full after Finish() returns, you must make room in the output buffer and call Finish() again. If Finish() returns and the output buffer is not full, then the encoding is finished.

You may use the same encoder object for multiple encode operations.

Requirements

Namespace: Hunny.Mime

Assembly: Hunny.Mime (in Hunny.Mime.dll)

See Also

QuotedPrintableEncoder Members | Hunny.Mime Namespace | QuotedPrintableEncoderW | Quoted-printable in RFC 2045