Encoding
- iOS
- 8.0+
- macOS
- 10.10+
- tvOS
- 9.0+
- watchOS
- 2.0+
struct Encoding
struct Encoding
import FoundationEssentials
import Swift
@frozen struct String
A 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 CompareOptions
These options apply to the various search/find and comparison methods (except where noted).
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Escapable
protocol Hashable : Equatable
A 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 Sendable
init(rawValue: UInt)
static let ascii: String.Encoding
static let iso2022JP: String.Encoding
static let isoLatin1: String.Encoding
static let isoLatin2: String.Encoding
static let japaneseEUC: String.Encoding
static let macOSRoman: String.Encoding
static let nextstep: String.Encoding
static let nonLossyASCII: String.Encoding
static let shiftJIS: String.Encoding
static let symbol: String.Encoding
static let unicode: String.Encoding
static let utf16: String.Encoding
static let utf16BigEndian: String.Encoding
static let utf16LittleEndian: String.Encoding
static let utf32: String.Encoding
static let utf32BigEndian: String.Encoding
static let utf32LittleEndian: String.Encoding
static let utf8: String.Encoding
static let windowsCP1250: String.Encoding
static let windowsCP1251: String.Encoding
static let windowsCP1252: String.Encoding
static let windowsCP1253: String.Encoding
static let windowsCP1254: String.Encoding
var description: String { get }
var hashValue: Int { get }
var rawValue: UInt
static 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.