CFStringGetCStringHeader: CFString.h

Copies the character contents of a CFString object to a local C string buffer after converting the characters to a given encoding.

Boolean CFStringGetCString (
    CFStringRef theString, 
    char *buffer, 
    CFIndex bufferSize, 
    CFStringEncoding encoding
);
theString

Pass a reference to the CFString object whose contents you wish to access.

buffer

Pass a pointer to a C string buffer that you have allocated locally. The buffer must be at least bufferSize bytes in length. On return, the buffer contains the converted characters. If there is an error in conversion, the buffer contains only partial results.

bufferSize

Pass an integer specifying the length of the local buffer in bytes (accounting for the null-terminator byte).

encoding

Pass a constant of type CFStringEncoding that indentifies the encoding to which the character contents of the CFString object should be converted.

function result

TRUE upon success or FALSE if the conversion fails or the provided buffer is too small.

DISCUSSION

The CFStringGetCString function is useful when you need your own copy of a CFString object's character data as a C string. You also typically call it as a "backup" when a prior call to CFStringGetCStringPtr fails.


© 1999 Apple Computer, Inc. — (Last Updated 9/15/99)