<!--
{
  "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(UInt8)`](/documentation/Swift/Unicode/Scalar/init(_:)-2oo2e)

Creates a Unicode scalar with the specified numeric value.

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

Creates a duplicate of the given Unicode scalar.

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

Creates a Unicode scalar with the specified numeric value.

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

Creates a Unicode scalar with the specified numeric value.

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

Creates a Unicode scalar with the specified numeric value.

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

Creates a Unicode scalar with the specified value.

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

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

### Inspecting a Scalar

[`var value: UInt32`](/documentation/Swift/Unicode/Scalar/value)

A numeric representation of the Unicode scalar.

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

Properties of this scalar defined by the Unicode standard.

[`struct 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.

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

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

[`var isASCII: Bool`](/documentation/Swift/Unicode/Scalar/isASCII)

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

### Printing and Displaying a Scalar

[`var description: String`](/documentation/Swift/Unicode/Scalar/description)

A textual representation of the Unicode scalar.

[`func write<Target>(to: inout Target)`](/documentation/Swift/Unicode/Scalar/write(to:))

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

[`func escaped(asASCII: Bool) -> String`](/documentation/Swift/Unicode/Scalar/escaped(asASCII:))

Returns a string representation of the Unicode scalar.

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

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

[`var debugDescription: String`](/documentation/Swift/Unicode/Scalar/debugDescription)

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

[`var customMirror: Mirror`](/documentation/Swift/Unicode/Scalar/customMirror)

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

[`var customPlaygroundQuickLook: _PlaygroundQuickLook`](/documentation/Swift/Unicode/Scalar/customPlaygroundQuickLook)

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

### Comparing Scalars

[`static func == (Unicode.Scalar, Unicode.Scalar) -> Bool`](/documentation/Swift/Unicode/Scalar/==(_:_:))

Returns a Boolean value indicating whether two values are equal.

[`static func != (borrowing Self, borrowing Self) -> Bool`](/documentation/Swift/Unicode/Scalar/!=(_:_:))

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

[`static func < (Unicode.Scalar, Unicode.Scalar) -> Bool`](/documentation/Swift/Unicode/Scalar/_(_:_:))

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

### Creating Ranges of Scalars

[`static func ... (Self) -> PartialRangeFrom<Self>`](/documentation/Swift/Unicode/Scalar/...(_:)-9u9rz)

Returns a partial range extending upward from a lower bound.

[`static func ... (Self) -> PartialRangeThrough<Self>`](/documentation/Swift/Unicode/Scalar/...(_:)-7lhvp)

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

[`static func ... (Self, Self) -> ClosedRange<Self>`](/documentation/Swift/Unicode/Scalar/...(_:_:))

Returns a closed range that contains both of its bounds.

[`static func ..< (Self) -> PartialRangeUpTo<Self>`](/documentation/Swift/Unicode/Scalar/.._(_:))

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

[`static func ..< (Self, Self) -> Range<Self>`](/documentation/Swift/Unicode/Scalar/.._(_:_:))

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

### Structures

[`struct UTF8View`](/documentation/Swift/Unicode/Scalar/UTF8View)

### Instance Properties

[`var utf8: Unicode.Scalar.UTF8View`](/documentation/Swift/Unicode/Scalar/utf8)

### Type Aliases

[`typealias Output`](/documentation/Swift/Unicode/Scalar/Output)

### Default Implementations

[Comparable Implementations](/documentation/Swift/Unicode/Scalar/Comparable-Implementations)

[CustomDebugStringConvertible Implementations](/documentation/Swift/Unicode/Scalar/CustomDebugStringConvertible-Implementations)

[CustomReflectable Implementations](/documentation/Swift/Unicode/Scalar/CustomReflectable-Implementations)

[CustomStringConvertible Implementations](/documentation/Swift/Unicode/Scalar/CustomStringConvertible-Implementations)

[Equatable Implementations](/documentation/Swift/Unicode/Scalar/Equatable-Implementations)

[ExpressibleByUnicodeScalarLiteral Implementations](/documentation/Swift/Unicode/Scalar/ExpressibleByUnicodeScalarLiteral-Implementations)

[Hashable Implementations](/documentation/Swift/Unicode/Scalar/Hashable-Implementations)

[LosslessStringConvertible Implementations](/documentation/Swift/Unicode/Scalar/LosslessStringConvertible-Implementations)

[TextOutputStreamable Implementations](/documentation/Swift/Unicode/Scalar/TextOutputStreamable-Implementations)

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

---

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)