CFStringCreateWithCString(_:_:_:)
Creates an immutable string from a C string.
Declaration
func CFStringCreateWithCString(_ alloc: CFAllocator!, _ cStr: UnsafePointer<CChar>!, _ encoding: CFStringEncoding) -> CFString!Parameters
- alloc:
The allocator to use to allocate memory for the new string. Pass
NULLor Kcfallocatordefault to use the current default allocator. - cStr:
The
NULL-terminated C string to be used to create the CFString object. The string must use an 8-bit encoding. - encoding:
The encoding of the characters in the C string. The encoding must specify an 8-bit encoding.
Return Value
An immutable string containing cStr (after stripping off the NULL terminating character), or NULL if there was a problem creating the object. Ownership follows the The Create Rule.
Discussion
A C string is a string of 8-bit characters terminated with an 8-bit NULL. Unichar and Unichar32 are not considered C strings.
See Also
Creating a CFString
CFStringCreateArrayBySeparatingStrings(_:_:_:)CFStringCreateByCombiningStrings(_:_:_:)CFStringCreateCopy(_:_:)CFStringCreateFromExternalRepresentation(_:_:_:)CFStringCreateWithBytes(_:_:_:_:_:)CFStringCreateWithBytesNoCopy(_:_:_:_:_:_:)CFStringCreateWithCharacters(_:_:_:)CFStringCreateWithCharactersNoCopy(_:_:_:_:)CFStringCreateWithCStringNoCopy(_:_:_:_:)CFStringCreateWithFormatAndArguments(_:_:_:_:)CFStringCreateWithPascalString(_:_:_:)CFStringCreateWithPascalStringNoCopy(_:_:_:_:)CFStringCreateWithSubstring(_:_:_:)