<!--
{
  "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/UTF16/isLeadSurrogate(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s7UnicodeO5UTF16O15isLeadSurrogateySbs6UInt16VFZ"
  },
  "title" : "isLeadSurrogate(_:)"
}
-->

# isLeadSurrogate(_:)

Returns a Boolean value indicating whether the specified code unit is a
high-surrogate code unit.

```
static func isLeadSurrogate(_ x: Unicode.UTF16.CodeUnit) -> Bool
```

## Parameters

`x`

A UTF-16 code unit.

## Return Value

`true` if `x` is a high-surrogate code unit; otherwise,
`false`.

## Discussion

Here’s an example of checking whether each code unit in a string’s
`utf16` view is a lead surrogate. The `apple` string contains a single
emoji character made up of a surrogate pair when encoded in UTF-16.

```
let apple = "🍎"
for unit in apple.utf16 {
    print(UTF16.isLeadSurrogate(unit))
}
// Prints "true"
// Prints "false"
```

This method does not validate the encoding of a UTF-16 sequence beyond
the specified code unit. Specifically, it does not validate that a
low-surrogate code unit follows `x`.

---

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)