Main Page | Data Structures | File List | Data Fields | Globals

QpDecoderW.h File Reference


Detailed Description

QpDecoderW is a version of QpDecoder that accepts text with 16-bit Unicode characters. The difference is that QpDecoderW_decode() takes a Char16Buffer argument, while QpDecoder_decode() takes a Char8Buffer argument. QpDecoderW may be convenient to use with Java, .NET, or COM, where text most often consists of 16-bit Unicode characters.

If your program operates in an environment that uses the UTF-8 encoding of Unicode (Linux or Solaris, for example), then you can use the QpDecoder module without any problems, because the quoted-printable-encoded data uses only 7-bit characters.

Please see the documentation for QpDecoder.


Functions

int QpDecoderW_initialize (QpDecoderW *decoder)
 Initializes the decoder object.
void QpDecoderW_finalize (QpDecoderW *decoder)
 Finalizes the decoder object.
void QpDecoderW_setOutputCrLf (QpDecoderW *decoder, int b)
 Sets the CRLF end-of-line characters option.
int QpDecoderW_getOutputCrLf (QpDecoderW *decoder)
 Gets the CRLF end-of-line characters option.
void QpDecoderW_start (QpDecoderW *decoder)
 Starts a decode operation.
void QpDecoderW_decode (QpDecoderW *decoder, Char16Buffer *inBuf, ByteBuffer *outBuf)
 Decodes data from the input buffer to the output buffer.
void QpDecoderW_finish (QpDecoderW *decoder, ByteBuffer *outBuf)
 Finishes a decode operation.
int QpDecoderW_errorStatus (QpDecoderW *decoder)
 Indicates if a decoding error occurred.


Function Documentation

void QpDecoderW_decode QpDecoderW *  decoder,
Char16Buffer inBuf,
ByteBuffer outBuf
 

Decodes data from the input buffer to the output buffer.

This function takes an input buffer and an output buffer as parameters, and decodes data from the input buffer to the output buffer until either (1) the input buffer is empty, or (2) the output buffer is full. Therefore, one of the following conditions is always true when the function returns:

  • inBuf.pos == inBuf.endPos (input buffer empty)
  • outBuf.pos == outBuf.endPos (output buffer full)

You may call the function multiple times to decode multiple buffers of input data. However, both of the following conditions should be true before the function is called:

  • inBuf.pos < inBuf.endPos (input buffer data available)
  • outBuf.pos < outBuf.endPos (output buffer space available)

Parameters:
decoder the decoder object
inBuf input buffer
outBuf output buffer

int QpDecoderW_errorStatus QpDecoderW *  decoder  ) 
 

Indicates if a decoding error occurred.

The QpDecoderW module correctly decodes all data that is correctly encoded. However, if the data is not correctly encoded, the decoder detects these errors. Because the data is typically text that is presented to a human user, it makes sense for the decoder to be "forgiving" of errors. (Humans are much better at recovering from errors than computers are!) Therefore, decoding errors are not treated as fatal errors. Instead, the decoder tries to recover as best it can and continue. In most cases, if the decoder detects a decoding error, it just passes the encoded data through to the output until it can recover from the error.

You can check for a decoding error by calling QpDecoderW_errorStatus() to get the value of the error flag. This flag is reset when you call QpDecoderW_start() and is set whenever the decoder detects an error.

Parameters:
decoder the decoder object
Returns:
true if an error occurred during the last decode operation

void QpDecoderW_finalize QpDecoderW *  decoder  ) 
 

Finalizes the decoder object.

You must call this function when you have finished using the decoder. Failure to call this function causes a memory leak.

Parameters:
decoder the decoder object

void QpDecoderW_finish QpDecoderW *  decoder,
ByteBuffer outBuf
 

Finishes a decode operation.

When you perform a decode operation, the decoder buffers some data internally. Therefore, after you have processed all the input data, you must call this function to flush the internal buffer.

The following condition must be true when the function is called:

  • outBuf.pos < outBuf.endPos (output buffer space available)

The above condition must also be true when the function returns in order to guarantee that all output data has been written to the output buffer. If the condition is false when the function returns, you must make room in the output buffer and call the function again.

Parameters:
decoder the decoder object
outBuf output buffer

int QpDecoderW_getOutputCrLf QpDecoderW *  decoder  ) 
 

Gets the CRLF end-of-line characters option.

Parameters:
decoder the decoder object
Returns:
boolean value of this option

int QpDecoderW_initialize QpDecoderW *  decoder  ) 
 

Initializes the decoder object.

You must initialize the decoder object before you use it. After you have initialized it, you may use the decoder object for multiple decode operations.

When you have finished using the decoder object, call QpDecoderW_finalize() to free the memory allocated by the decoder object.

Parameters:
decoder the decoder object
Returns:
0 if successful; -1 if unsuccessful

void QpDecoderW_setOutputCrLf QpDecoderW *  decoder,
int  b
 

Sets the CRLF end-of-line characters option.

If this option is true, then the decoder outputs CR LF as the end-of-line character sequence for hard line breaks. If the option is set to false, then the decoder outputs LF alone.

The default value is false.

Parameters:
decoder the decoder object
b true value causes CR LF in the output; false causes LF

void QpDecoderW_start QpDecoderW *  decoder  ) 
 

Starts a decode operation.

After you call QpDecoderW_start(), you call QpDecoderW_decode() one or more times, followed by QpDecoderW_finish() to complete the decode operation.

Parameters:
decoder the decoder object

Copyright © 2001-2006 Hunny Software, Inc. All rights reserved.