<!--
{
  "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/String/init(cString:)-6kr8s",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SS7cStringSSSPys5UInt8VG_tcfc"
  },
  "title" : "init(cString:)"
}
-->

# init(cString:)

Creates a new string by copying the null-terminated UTF-8 data referenced
by the given pointer.

```
init(cString nullTerminatedUTF8: UnsafePointer<UInt8>)
```

## Parameters

`nullTerminatedUTF8`


A pointer to a null-terminated sequence of UTF-8 code units.

## Discussion

This is identical to `init(cString: UnsafePointer<CChar>)` but operates on
an unsigned sequence of bytes.

---

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)