---
title: "init(_:encoding:)"
framework: wifiinfrastructure
role: symbol
role_heading: Initializer
path: "wifiinfrastructure/wissid/init(_:encoding:)"
---

# init(_:encoding:)

Creates an SSID from a text string using the specified encoding.

## Declaration

```swift
init?(_ ssid: String, encoding: String.Encoding = .utf8)
```

## Parameters

- `ssid`: The network name as a string.
- `encoding`: The text encoding to use for conversion. Defaults to UTF-8.

## Return Value

Return Value A new SSID, or nil if the string can’t be encoded or results in invalid data length.

## Discussion

Discussion Use this initializer to create SSIDs from human-readable network names. The method converts the string to binary data using the specified encoding before validating against length requirements.

## See Also

### Working with SSIDs as a string

- [stringRepresentation(encoding:)](wifiinfrastructure/wissid/stringrepresentation(encoding:).md)
