Generic Initializer

init(decoding:as:)

Creates a string from the given Unicode code units in the specified encoding.

Declaration

init<C, Encoding>(decoding codeUnits: C, as sourceEncoding: Encoding.Type) where C : Collection, Encoding : _UnicodeEncoding, C.Element == Encoding.CodeUnit

Parameters

codeUnits

A collection of code units encoded in the encoding specified in sourceEncoding.

sourceEncoding

The encoding in which codeUnits should be interpreted.

Relationships

From Protocol

See Also

Creating a String from Unicode Data

init?(utf8String: UnsafePointer<CChar>)

Produces a string created by copying the data from a given C array of UTF8-encoded bytes.

init?(validatingUTF8: UnsafePointer<CChar>)

Creates a new string by copying and validating the null-terminated UTF-8 data referenced by the given pointer.

init(utf16CodeUnits: UnsafePointer<unichar>, count: Int)

Returns an initialized String object that contains a given number of characters from a given array of Unicode characters.

init(utf16CodeUnitsNoCopy: UnsafePointer<unichar>, count: Int, freeWhenDone: Bool)

Returns an initialized String object that contains a given number of characters from a given array of UTF-16 Code Units