Class that performs quoted-printable decoding.
For a list of all members of this type, see QuotedPrintableDecoder Members.
System.Object
QuotedPrintableDecoder
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:
Output CR LF If you set this option to true,
then the decoder uses CR LF as the end-of-line characters for hard
line breaks in the decoded output. If you set this option to false,
then the decoder uses LF alone. The default value is true if
TextUtil.EOL is TextUtil.CRLF_EOL.
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:
Start() to initialize the decoder. 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. DecodeSegment() with the input buffer
and output buffer as arguments. 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. 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.
Namespace: Hunny.Mime
Assembly: Hunny.Mime (in Hunny.Mime.dll)
QuotedPrintableDecoder Members | Hunny.Mime Namespace | QuotedPrintableDecoderW | Quoted-printable in RFC 2045