<!--
{
  "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/init(_:)-96l5f",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s7UnicodeO6ScalarVyADSgSicfc"
  },
  "title" : "init(_:)"
}
-->

# init(_:)

Creates a Unicode scalar with the specified numeric value.

```
init?(_ v: Int)
```

## Parameters

`v`

The Unicode code point to use for the scalar. `v` must be
a valid Unicode scalar value, in the ranges `0...0xD7FF` or
`0xE000...0x10FFFF`. In case of an invalid unicode scalar value, nil is
returned.

## Discussion

For example, the following code sample creates a `Unicode.Scalar` instance
with a value of an emoji character:

```
let codepoint = 127881
let emoji = Unicode.Scalar(codepoint)!
print(emoji)
// Prints "🎉"
```

In case of an invalid input value, nil is returned.

```
let codepoint: UInt32 = extValue // This might be an invalid value.
if let emoji = Unicode.Scalar(codepoint) {
  print(emoji)
} else {
  // Do something else
}
```

---

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)