Creates a new string by copying the null-terminated UTF-8 data referenced by the given pointer.
SDK
- Xcode 8.0+
Framework
- Swift Standard Library
Declaration
Parameters
cString
A pointer to a null-terminated UTF-8 code sequence.
Discussion
If c
contains ill-formed UTF-8 code unit sequences, this initializer replaces them with the Unicode replacement character ("\u{FFFD}"
).
The following example calls this initializer with pointers to the contents of two different CChar
arrays—the first with well-formed UTF-8 code unit sequences and the second with an ill-formed sequence at the end.