InitializerSwift
init(bytes:encoding:)
iOS 8.0+
iPadOS 8.0+
Mac Catalyst 8.0+
macOS 10.10+
tvOS 9.0+
watchOS 2.0+
Creates a new string equivalent to the given bytes interpreted in the specified encoding. Note: This API does not interpret embedded nulls as termination of the string. Use
String?(validatingCString:) instead for null-terminated C strings.init?<S>(bytes: S, encoding: String.Encoding) where S : Sequence, S.Element == UInt8
Parameters
bytesA sequence of bytes to interpret using
encoding.encodingThe encoding to use to interpret
bytes.