<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSString/init(utf8String:)-vg2b",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSString(im)initWithUTF8String:"
  },
  "title" : "init(utf8String:)"
}
-->

# init(utf8String:)

Returns an @c NSString object initialized by copying the characters from a given C array of UTF8-encoded bytes.

```
convenience init?(utf8String nullTerminatedCString: UnsafePointer<CChar>)
```

## Parameters

`nullTerminatedCString`

A @c NULL-terminated C array of bytes in UTF-8 encoding. This value must not be @c NULL.

## Return Value

An @c NSString object initialized by copying the bytes from @c nullTerminatedCString. The returned object may be different from the original receiver.

---

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)