Encoding
- iOS
 - 8.0+
 - macOS
 - 10.10+
 - tvOS
 - 9.0+
 - watchOS
 - 2.0+
 
You’re reading documentation from an older version of Swift 6.1.
This symbol may have changed its signature in the latest stable release of Swift 6.1.
struct EncodingYou’re reading documentation from an older version of Swift 6.1.
This symbol may have changed its signature in the latest stable release of Swift 6.1.
struct Encodingimport Swiftimport FoundationEssentials@frozen struct StringA Unicode string value that is a collection of characters.
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, 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, 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 CompareOptionsThese options apply to the various search/find and comparison methods (except where noted).
protocol CopyableA type whose values can be implicitly or explicitly copied.
protocol CustomStringConvertibleA type with a customized textual representation.
protocol EquatableA type that can be compared for value equality.
protocol Escapableprotocol Hashable : EquatableA type that can be hashed into a Hasher to produce an integer hash value.
protocol RawRepresentable<RawValue>A type that can be converted to and from an associated raw value.
protocol Sendableinit(rawValue: UInt) static let ascii: String.Encodingstatic let iso2022JP: String.Encodingstatic let isoLatin1: String.Encodingstatic let isoLatin2: String.Encodingstatic let japaneseEUC: String.Encodingstatic let macOSRoman: String.Encodingstatic let nextstep: String.Encodingstatic let nonLossyASCII: String.Encodingstatic let shiftJIS: String.Encodingstatic let symbol: String.Encodingstatic let unicode: String.Encodingstatic let utf16: String.Encodingstatic let utf16BigEndian: String.Encodingstatic let utf16LittleEndian: String.Encodingstatic let utf32: String.Encodingstatic let utf32BigEndian: String.Encodingstatic let utf32LittleEndian: String.Encodingstatic let utf8: String.Encodingstatic let windowsCP1250: String.Encodingstatic let windowsCP1251: String.Encodingstatic let windowsCP1252: String.Encodingstatic let windowsCP1253: String.Encodingstatic let windowsCP1254: String.Encodingvar description: String { get }var hashValue: Int { get }var rawValue: UIntstatic func == (lhs: String.Encoding, rhs: String.Encoding) -> Bool func hash(into hasher: inout Hasher) static func != (lhs: Self, rhs: Self) -> Bool Returns a Boolean value indicating whether two values are not equal.