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

# init(_:)

Creates a Unicode scalar with the specified numeric value.

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

## Parameters

`v`

The Unicode code point to use for the scalar. The
initializer succeeds if `v` is a valid Unicode scalar value, in the
range `0...0xD7FF` or `0xE000...0x10FFFF`. If `v` is an invalid
unicode scalar value, the result is `nil`.

## Discussion

For example, the following code sample creates a `Unicode.Scalar`
instance with a value of `"밥"`, the Korean word for rice:

```
let codepoint: UInt16 = 48165
let bap = Unicode.Scalar(codepoint)
print(bap!)
// Prints "밥"
```

In case of an invalid input value, the result is `nil`.

```
let codepoint: UInt16 = extValue   // This might be an invalid value
if let bap = Unicode.Scalar(codepoint) {
    print(bap)
} 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)