Creates a string from a buffer, containing characters in a specified encoding, that might serve as the backing store for the new string.
- iOS 2.0+
- macOS 10.5+
- tvOS 9.0+
- watchOS 2.0+
- Core Foundation
The allocator to use to allocate memory for the new CFString object. Pass
kto use the current default allocator.
A buffer containing characters in the encoding specified by
encoding. The buffer must not contain a length byte (as in Pascal buffers) or any terminating
NULLcharacter (as in C buffers).
The number of bytes in
The character encoding of
trueif the characters in the byte buffer are in an “external representation” format—that is, whether the buffer contains a BOM (byte order marker). This is usually the case for bytes that are read in from a text file or received over the network. Otherwise, pass
The allocator to use to deallocate
byteswhen it is no longer needed. You can pass
kto request the default allocator for this purpose. If the buffer does not need to be deallocated, or if you want to assume responsibility for deallocating the buffer (and not have the string deallocate it), pass
A new string whose contents are
bytes. Ownership follows the The Create Rule.
This function takes an explicit length, and allows you to specify whether the data is an external format—that is, whether to pay attention to the BOM character (if any) and do byte swapping if necessary
If an error occurs during the creation of the string, then
bytes is not deallocated. In this case, the caller is responsible for freeing the buffer. This allows the caller to continue trying to create a string with the buffer, without having the buffer deallocated.