<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Unicode/UTF8",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s7UnicodeO4UTF8O"
  },
  "title" : "Unicode.UTF8"
}
-->

# Unicode.UTF8

```
@frozen enum UTF8
```

## Topics

### Structures

[`struct ForwardParser`](/documentation/Swift/Unicode/UTF8/ForwardParser)

A type that can be used to parse `CodeUnits` into
`EncodedScalar`s.

[`struct ReverseParser`](/documentation/Swift/Unicode/UTF8/ReverseParser)

A type that can be used to parse a reversed sequence of
`CodeUnits` into `EncodedScalar`s.

[`struct ValidationError`](/documentation/Swift/Unicode/UTF8/ValidationError)

The kind and location of a UTF-8 encoding error.

### Type Aliases

[`typealias CodeUnit`](/documentation/Swift/Unicode/UTF8/CodeUnit)

The basic unit of encoding

[`typealias EncodedScalar`](/documentation/Swift/Unicode/UTF8/EncodedScalar)

A valid scalar value as represented in this encoding

### Type Properties

[`static var encodedReplacementCharacter: Unicode.UTF8.EncodedScalar`](/documentation/Swift/Unicode/UTF8/encodedReplacementCharacter)

A unicode scalar value to be used when repairing
encoding/decoding errors, as represented in this encoding.

### Type Methods

[`static func decode(Unicode.UTF8.EncodedScalar) -> Unicode.Scalar`](/documentation/Swift/Unicode/UTF8/decode(_:)-swift.type.method)

Converts from encoded to encoding-independent representation

[`static func encode(Unicode.Scalar) -> Unicode.UTF8.EncodedScalar?`](/documentation/Swift/Unicode/UTF8/encode(_:))

Converts from encoding-independent to encoded representation, returning
`nil` if the scalar can’t be represented in this encoding.

[`static func isASCII(Unicode.UTF8.CodeUnit) -> Bool`](/documentation/Swift/Unicode/UTF8/isASCII(_:))

Returns whether the given code unit represents an ASCII scalar

[`static func isContinuation(Unicode.UTF8.CodeUnit) -> Bool`](/documentation/Swift/Unicode/UTF8/isContinuation(_:))

Returns a Boolean value indicating whether the specified code unit is a
UTF-8 continuation byte.

[`static func transcode<FromEncoding>(FromEncoding.EncodedScalar, from: FromEncoding.Type) -> Unicode.UTF8.EncodedScalar?`](/documentation/Swift/Unicode/UTF8/transcode(_:from:))

Converts a scalar from another encoding’s representation, returning
`nil` if the scalar can’t be represented in this encoding.

[`static func width(Unicode.Scalar) -> Int`](/documentation/Swift/Unicode/UTF8/width(_:))

Returns the number of code units required to encode the given Unicode
scalar.

### Default Implementations

[UnicodeCodec Implementations](/documentation/Swift/Unicode/UTF8/UnicodeCodec-Implementations)

## Relationships

### Conforms To

[`BitwiseCopyable`](/documentation/Swift/BitwiseCopyable)

[`UnicodeCodec`](/documentation/Swift/UnicodeCodec)

[`Escapable`](/documentation/Swift/Escapable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Copyable`](/documentation/Swift/Copyable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)