TECFlushText
Flushes out any data in a converter object’s temporarybuffers and resets the converter object.
Declaration
OSStatus TECFlushText(TECObjectRef encodingConverter, TextPtr outputBuffer, ByteCount outputBufferLength, ByteCount *actualOutputLength);Parameters
- encodingConverter:
A reference to the text converter object whose contents are to be flushed. This can be a reference returned by the 1571815 Teccreateconverter or 1571829 Teccreateconverterfrompath functions.
- outputBuffer:
On return, a pointer to a buffer that holds the converted text.
- outputBufferLength:
The length in bytes of the buffer provided by the
outputBufferparameter. - actualOutputLength:
On return, a pointer to the number of bytes of converted text returned in the buffer specified by the
outputBufferparameter.
Return Value
A resultcode. See Result Codes.
Discussion
You should always call TECFlushText whenyou finish converting a text stream. If you are converting a singlestream in multiple chunks using multiple calls to TECConvertText,you only need to call TECFlushText afterthe last call to TECConvertText forthat stream. The function uses the conversion path specified inthe converter object you supply.
For the function to return successfully, the output bufferyou allocate must be large enough to accommodate the flushed text.If the output buffer is too small to accommodate any flushed text,the function will fail. For best results, you should follow theseguidelines when you allocate an output buffer:
Base the buffer length on an estimate of thebyte requirements of the destination encoding. Make sure you accountfor additional bytes needed by the destination encoding (for example,an escape sequence) in addition to the actual text.
Always allocate a buffer at least 32 bytes long.
Encodings such as ISO-2022 that need to shift back to a certaindefault state at the end of a conversion can do so when this functionis called.