---
title: utf8String
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/nsstring/utf8string
---

# utf8String

A null-terminated UTF8 representation of the string.

## Declaration

```swift
var utf8String: UnsafePointer<CChar>? { get }
```

## Discussion

Discussion This C string is a pointer to a structure inside the string object, which may have a lifetime shorter than the string object and will certainly not have a longer lifetime. Therefore, you should copy the C string if it needs to be stored outside of the memory context in which you use this property.

## See Also

### Getting C Strings

- [cString(using:)](foundation/nsstring/cstring(using:).md)
- [getCString(_:maxLength:encoding:)](foundation/nsstring/getcstring(_:maxlength:encoding:).md)
