<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/String/init(decoding:)-nm7v",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SS6SystemE8decodingSSAA8FilePathV_tcfc"
  },
  "title" : "init(decoding:)"
}
-->

# init(decoding:)

Creates a string by interpreting the file path’s content as UTF-8 on Unix
and UTF-16 on Windows.

```
init(decoding path: FilePath)
```

## Parameters

`path`

The file path to be interpreted as
`CInterop.PlatformUnicodeEncoding`.

## Discussion

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

---

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)