Hunny Software Library Reference

QuotedPrintableDecoder Class

Class that performs quoted-printable decoding.

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

System.Object
   QuotedPrintableDecoder

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

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.

QuotedPrintableDecoder provides two interfaces for performing quoted-printable decoding.

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

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

QuotedPrintableDecoder allows you to change certain options, which affect the behavior of the decoder:

Using the Low-Level Interface

The low-level interface allows you to decode data one buffer at a time; thus you may decode data of unlimited size using a limited amount of memory. For example, if you want to decode 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 decoder, and write to the output file one buffer at a time.

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

  1. Call Start() to initialize the decoder.
  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 decoded, 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 DecodeSegment() 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 DecodeSegment() 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 DecodeSegment() 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 decoding is finished.

You may use the same decoder object for multiple decode operations.

Dealing With Errors

The decoder correctly decodes all data that is correctly encoded. However, if the data is not correctly encoded, the decoder detects these errors. All decoding errors are treated as non-fatal errors -- the decoder tries to recover. After a decode operation, you may get the ErrorDetected property to discover if the decoder detected a decoding error.

Requirements

Namespace: Hunny.Mime

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

See Also

QuotedPrintableDecoder Members | Hunny.Mime Namespace | QuotedPrintableDecoderW | Quoted-printable in RFC 2045