---
title: "init(validatingPlatformString:)"
framework: swift
role: symbol
role_heading: Initializer
path: "swift/string/init(validatingplatformstring:)-91z6f"
---

# init(validatingPlatformString:)

Creates a string by interpreting the null-terminated platform string as UTF-8 on Unix and UTF-16 on Windows.

## Declaration

```swift
init?(validatingPlatformString platformString: [CInterop.PlatformChar])
```

## Parameters

- `platformString`: The null-terminated platform string to be interpreted as CInterop.PlatformUnicodeEncoding.

## Discussion

Discussion Note It is a precondition that platformString must be null-terminated. The absence of a null byte will trigger a runtime error. If the contents of the platform string isn’t well-formed Unicode, this initializer returns nil.
