<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/String/init(platformString:)-5j2y3",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SS6SystemE14platformStringSSSPys4Int8VG_tcfc"
  },
  "title" : "init(platformString:)"
}
-->

# init(platformString:)

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

```
init(platformString: UnsafePointer<CInterop.PlatformChar>)
```

## Parameters

`platformString`

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

## Discussion

If the content of the platform string isn’t well-formed Unicode,
this initializer replaces invalid bytes with U+FFFD.
This means that, depending on the semantics of the specific platform,
conversion to a string and back might result in a value that’s different
from the original platform string.

---

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)