Contents

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 NULL or 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