UTF16
@frozen enum UTF16
Citizens in Swift
Conformances
protocol Sendable
A type whose values can safely be passed across concurrency domains by copying.
protocol UnicodeCodec
A Unicode encoding form that translates between Unicode scalar values and form-specific code units.
Members
init(
) Creates an instance of the UTF-16 codec.
static var encodedReplacementCharacter: Unicode.UTF16.EncodedScalar
static func decode(Unicode
.UTF16.EncodedScalar) -> Unicode.Scalar static func encode(Unicode
.Scalar) -> Unicode.UTF16.EncodedScalar? static func encode(Unicode
.Scalar, into: (Unicode.UTF16.CodeUnit) -> Void) Encodes a Unicode scalar as a series of code units by calling the given closure on each code unit.
static func isASCII(Unicode
.UTF16.CodeUnit) -> Bool Returns whether the given code unit represents an ASCII scalar
static func isLeadSurrogate(Unicode
.UTF16.CodeUnit) -> Bool Returns a Boolean value indicating whether the specified code unit is a high-surrogate code unit.
static func isSurrogate(Unicode
.UTF16.CodeUnit) -> Bool Returns a Boolean value indicating whether the specified code unit is a high or low surrogate code unit.
static func isTrailSurrogate(Unicode
.UTF16.CodeUnit) -> Bool Returns a Boolean value indicating whether the specified code unit is a low-surrogate code unit.
static func leadSurrogate(Unicode
.Scalar) -> UTF16.CodeUnit Returns the high-surrogate code unit of the surrogate pair representing the specified Unicode scalar.
static func trailSurrogate(Unicode
.Scalar) -> UTF16.CodeUnit Returns the low-surrogate code unit of the surrogate pair representing the specified Unicode scalar.
static func transcode<FromEncoding>(FromEncoding
.EncodedScalar, from: FromEncoding.Type) -> Unicode.UTF16.EncodedScalar? static func transcodedLength<Input, Encoding>(of: Input, decodedAs: Encoding.Type, repairingIllFormedSequences: Bool
) -> (count: Int, isASCII: Bool)? Returns the number of UTF-16 code units required for the given code unit sequence when transcoded to UTF-16, and a Boolean value indicating whether the sequence was found to contain only ASCII characters.
static func width(Unicode
.Scalar) -> Int Returns the number of code units required to encode the given Unicode scalar.
func decode<I>(inout I
) -> UnicodeDecodingResult Starts or continues decoding a UTF-16 sequence.
struct ForwardParser
struct ReverseParser
typealias CodeUnit
typealias EncodedScalar