init(contentsOf:encoding:)
Produces a string created by reading data from a given URL interpreted using a given encoding.
- iOS
- 8.0+
- macOS
- 10.10+
- tvOS
- 9.0+
- watchOS
- 2.0+
init(contentsOf url: URL, encoding enc: String.Encoding) throws
Produces a string created by reading data from a given URL interpreted using a given encoding.
init(contentsOf url: URL, encoding enc: String.Encoding) throws
sSS20FoundationEssentialsE10contentsOf8encodingSSAA3URLVh_SSAAE8EncodingVtKcfc
What are these?6K54K
import Swift
import FoundationEssentials
@frozen struct String
A Unicode string value that is a collection of characters.
struct URL
A URL is a type that can potentially contain the location of a resource on a remote server, the path of a local file on disk, or even an arbitrary piece of encoded data.
struct Encoding
init(_ characters: Slice<AttributedString.CharacterView>)
init?<S>(bytes: S, encoding: String.Encoding) where S : Sequence, S.Element == UInt8
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(contentsOf url: URL, usedEncoding: inout String.Encoding) throws
Produces a string created by reading data from a given URL and returns by reference the encoding used to interpret the data.
init(contentsOfFile path: String, encoding enc: String.Encoding) throws
Produces a string created by reading data from the file at a given path interpreted using a given encoding.
init(contentsOfFile path: String, usedEncoding: inout String.Encoding) throws
Produces a string created by reading data from the file at a given path and returns by reference the encoding used to interpret the file.
init?(data: Data, encoding: String.Encoding)
Returns a String
initialized by converting given data
into Unicode characters using a given encoding
.
func data(using encoding: String.Encoding, allowLossyConversion: Bool = false) -> Data?
func withFileSystemRepresentation<R>(_ block: (UnsafePointer<CChar>?) throws -> R) rethrows -> R
func withMutableFileSystemRepresentation<R>(_ block: (UnsafeMutablePointer<CChar>?) throws -> R) rethrows -> R
struct CompareOptions
These options apply to the various search/find and comparison methods (except where noted).