CFStringGetCStringPtr(_:_:)
Quickly obtains a pointer to a C-string buffer containing the characters of a string in a given encoding.
Declaration
func CFStringGetCStringPtr(_ theString: CFString!, _ encoding: CFStringEncoding) -> UnsafePointer<CChar>!Parameters
- theString:
The string whose contents you wish to access.
- encoding:
The string encoding to which the character contents of
theStringshould be converted. The encoding must specify an 8-bit encoding.
Return Value
A pointer to a C string or NULL if the internal storage of theString does not allow this to be returned efficiently.
Discussion
This function either returns the requested pointer immediately, with no memory allocations and no copying, in constant time, or returns NULL. If the latter is the result, call an alternative function such as the CFStringGetCString(_:_:_:_:) function to extract the characters.
Whether or not this function returns a valid pointer or NULL depends on many factors, all of which depend on how the string was created and its properties. In addition, the function result might change between different releases and on different platforms. So do not count on receiving a non-NULL result from this function under any circumstances.
See Also
Accessing Characters
CFStringCreateExternalRepresentation(_:_:_:_:)CFStringGetBytes(_:_:_:_:_:_:_:_:)CFStringGetCharacterAtIndex(_:_:)CFStringGetCharacters(_:_:_:)CFStringGetCharactersPtr(_:)CFStringGetCharacterFromInlineBuffer(_:_:)CFStringGetCString(_:_:_:_:)CFStringGetLength(_:)CFStringGetPascalString(_:_:_:_:)CFStringGetPascalStringPtr(_:_:)CFStringGetRangeOfComposedCharactersAtIndex(_:_:)CFStringInitInlineBuffer(_:_:_:)