Initializer

init(bytes:length:encoding:)

Returns an initialized NSString object containing a given number of bytes from a given buffer of bytes interpreted in a given encoding.

Declaration

convenience init?(bytes: UnsafeRawPointer, length len: Int, encoding: UInt)

Parameters

bytes

A buffer of bytes interpreted in the encoding specified by encoding.

length

The number of bytes to use from bytes.

encoding

The character encoding applied to bytes. For possible values, see NSStringEncoding.

Return Value

An initialized NSString object containing length bytes from bytes interpreted using the encoding encoding. The returned object may be different from the original receiver.

The return byte strings are allowed to be unterminated.

If the length of the byte string is greater than the specified length a nil value is returned.

See Also

Related Symbols

init?(bytesNoCopy: UnsafeMutableRawPointer, length: Int, encoding: UInt, freeWhenDone: Bool)

Returns an initialized NSString object that contains a given number of bytes from a given buffer of bytes interpreted in a given encoding, and optionally frees the buffer.