<!--
{
  "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/Scalar",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s7UnicodeO6ScalarV"
  },
  "title" : "Unicode.Scalar"
}
-->

# Unicode.Scalar

A Unicode scalar value.

```
@frozen struct Scalar
```

## Overview

The `Unicode.Scalar` type, representing a single Unicode scalar value, is
the element type of a string’s `unicodeScalars` collection.

You can create a `Unicode.Scalar` instance by using a string literal that
contains a single character representing exactly one Unicode scalar value.

```
let letterK: Unicode.Scalar = "K"
let kim: Unicode.Scalar = "김"
print(letterK, kim)
// Prints "K 김"
```

You can also create Unicode scalar values directly from their numeric
representation.

```
let airplane = Unicode.Scalar(9992)!
print(airplane)
// Prints "✈︎"
```

## Topics

### Creating a Scalar

[`init(_:)`](/documentation/Swift/Unicode/Scalar/init(_:)-2oo2e)

Creates a Unicode scalar with the specified numeric value.

[`init(_:)`](/documentation/Swift/Unicode/Scalar/init(_:)-5d6us)

Creates a duplicate of the given Unicode scalar.

[`init(_:)`](/documentation/Swift/Unicode/Scalar/init(_:)-9eo1y)

Creates a Unicode scalar with the specified numeric value.

[`init(_:)`](/documentation/Swift/Unicode/Scalar/init(_:)-18u1m)

Creates a Unicode scalar with the specified numeric value.

[`init(_:)`](/documentation/Swift/Unicode/Scalar/init(_:)-96l5f)

Creates a Unicode scalar with the specified numeric value.

[`init(unicodeScalarLiteral:)`](/documentation/Swift/Unicode/Scalar/init(unicodeScalarLiteral:))

Creates a Unicode scalar with the specified value.

[`init(_:)`](/documentation/Swift/Unicode/Scalar/init(_:)-4p868)

Instantiates an instance of the conforming type from a string
representation.

### Inspecting a Scalar

[`value`](/documentation/Swift/Unicode/Scalar/value)

A numeric representation of the Unicode scalar.

[`properties`](/documentation/Swift/Unicode/Scalar/properties-swift.property)

Properties of this scalar defined by the Unicode standard.

[`Unicode.Scalar.Properties`](/documentation/Swift/Unicode/Scalar/Properties-swift.struct)

A value that provides access to properties of a Unicode scalar that are
defined by the Unicode standard.

[`hash(into:)`](/documentation/Swift/Unicode/Scalar/hash(into:))

Hashes the essential components of this value by feeding them into the
given hasher.

[`isASCII`](/documentation/Swift/Unicode/Scalar/isASCII)

A Boolean value indicating whether the Unicode scalar is an ASCII
character.

### Printing and Displaying a Scalar

[`description`](/documentation/Swift/Unicode/Scalar/description)

A textual representation of the Unicode scalar.

[`write(to:)`](/documentation/Swift/Unicode/Scalar/write(to:))

Writes the textual representation of the Unicode scalar into the given
output stream.

[`escaped(asASCII:)`](/documentation/Swift/Unicode/Scalar/escaped(asASCII:))

Returns a string representation of the Unicode scalar.

[`utf16`](/documentation/Swift/Unicode/Scalar/utf16)

[`Unicode.Scalar.UTF16View`](/documentation/Swift/Unicode/Scalar/UTF16View)

[`debugDescription`](/documentation/Swift/Unicode/Scalar/debugDescription)

An escaped textual representation of the Unicode scalar, suitable for
debugging.

[`customMirror`](/documentation/Swift/Unicode/Scalar/customMirror)

A mirror that reflects the `Unicode.Scalar` instance.

[`customPlaygroundQuickLook`](/documentation/Swift/Unicode/Scalar/customPlaygroundQuickLook)

A custom playground Quick Look for the `Unicode.Scalar` instance.

### Comparing Scalars

[`==(_:_:)`](/documentation/Swift/Unicode/Scalar/==(_:_:))

Returns a Boolean value indicating whether two values are equal.

[`!=(_:_:)`](/documentation/Swift/Unicode/Scalar/!=(_:_:))

Returns a Boolean value indicating whether two values are not equal.

[`<(_:_:)`](/documentation/Swift/Unicode/Scalar/_(_:_:))

Returns a Boolean value indicating whether the value of the first
argument is less than that of the second argument.

[`<=(_:_:)`](/documentation/Swift/Unicode/Scalar/_=(_:_:)-13yar)

Returns a Boolean value indicating whether the value of the first argument
is less than or equal to that of the second argument.

[`>(_:_:)`](/documentation/Swift/Unicode/Scalar/_(_:_:)-1xeim)

Returns a Boolean value indicating whether the value of the first argument
is greater than that of the second argument.

[`>=(_:_:)`](/documentation/Swift/Unicode/Scalar/_=(_:_:)-7oywq)

Returns a Boolean value indicating whether the value of the first argument
is greater than or equal to that of the second argument.

### Creating Ranges of Scalars

[`...(_:)`](/documentation/Swift/Unicode/Scalar/...(_:)-9u9rz)

Returns a partial range extending upward from a lower bound.

[`...(_:)`](/documentation/Swift/Unicode/Scalar/...(_:)-7lhvp)

Returns a partial range up to, and including, its upper bound.

[`...(_:_:)`](/documentation/Swift/Unicode/Scalar/...(_:_:))

Returns a closed range that contains both of its bounds.

[`..<(_:)`](/documentation/Swift/Unicode/Scalar/.._(_:))

Returns a partial range up to, but not including, its upper bound.

[`..<(_:_:)`](/documentation/Swift/Unicode/Scalar/.._(_:_:))

Returns a half-open range that contains its lower bound but not its upper
bound.



---

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)
