Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Up Previous Next 

PATH 
Mac OS 8 and 9 Developer Documentation > Text Encoding Conversion Manager
Programming With the Text Encoding Conversion Manager



TECFlushText

Flushes out any data that may be stored in a converter object's temporary buffers and returns the converter object to its default state.

pascal OSStatus TECFlushText(
                     TECObjectRef encodingConverter,
                     TextPtr outputBuffer,
                     ByteCount outputBufferLength,
                     ByteCount *actualOutputLength);
encodingConverter
A reference to the text converter object, whose contents are to be flushed. This can be a reference returned by the function TECCreateConverter or TECCreateConverterFromPath.

outputBuffer
A pointer to a buffer for a byte stream. On output, this buffer holds the converted text.

outputBufferLength
The length in bytes of the buffer provided by the outputBuffer parameter.

actualOutputLength
A pointer to a value of type ByteCount. On output this value is the number of bytes of converted text returned in the buffer specified by the outputBuffer parameter.

function result
A result code. See Text Encoding Conversion Manager Result Codes for a list of possible values.

DISCUSSION

The TECFlushText function flushes out any data that may be stored in the temporary buffers in the specified text encoding converter object. Always call TECFlushText when you finish converting a text stream. If you are converting a single stream in multiple chunks using multiple calls to TECConvertText, you need call TECFlushText only after the last call to TECConvertText for that stream. The function relies on the specified converter object for information identifying the source encoding, the destination encoding, and any intermediate encodings required for conversion.

In allocating an output buffer, a good rule of thumb is larger is better, basing your estimate on the byte requirements of the destination encoding. You should always allocate a buffer at least 32 bytes long. For the function to return successfully, the output buffer you allocate must be large enough to accommodate the flushed text. If the output buffer you allocate is too small to accommodate any flushed text, the function will fail. For example, if the destination encoding requires additional bytes in addition to the actual text (for instance, an escape sequence preceding the converted text), your buffer must be large enough to accommodate both.

Encodings such as ISO-2022 that need to shift back to a certain default state at the end of a conversion can do so when this function is called.


© 1999 Apple Computer, Inc. – (Last Updated 13 Dec 99)

Up Previous Next