CFStringCreateWithBytes

Header: CFString.h Carbon status: Supported

Creates a CFString object from a buffer containing characters in a specified encoding.

CFStringRef CFStringCreateWithBytes (
    CFAllocatorRef alloc, 
    const UInt8 *bytes, 
    CFIndex numBytes, 
    CFStringEncoding encoding, 
    Boolean isExternalRepresentation
);
Parameter descriptions
alloc

Pass a reference to an allocator object to be used for the CFString object or pass NULL to request the default allocator.

bytes

Pass a pointer to a buffer containing the characters in the specified encoding.

numBytes

Pass an integer specifying the number of bytes in the buffer.

encoding

Pass an enum constant of type CFStringEncoding to specify the encoding of the characters in the buffer.

isExternalRepresentation

Pass true if the characters in the byte buffer are in an "external representation" format—that is, whether the buffer contains a BOM (byte order marker) and so whether byte swapping must take place. This is usually the case for bytes that are read in from a text file or received over the network. Otherwise, pass false.

function result

A reference to an immutable CFString object or NULL if there was a problem creating the object.

DISCUSSION

The CFStringCreateWithBytes function creates an immutable CFString object from a "raw" byte buffer—that is, a buffer containing 8-bit characters but no length byte (as in Pascal buffers) and no terminating NULL character (as in C buffers). The number of bytes in the buffer is provided in a parameter. The characters in the buffer should be in an 8-bit encoding; you specify this encoding in another parameter. This function handles character data in an "external representation" format by interpreting any BOM (byte order marker) character and performing any necessary byte swapping.

AVAILABILITY

Supported in Carbon. Available in Carbon 1.0.2 and later.


© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)