<!--
{
  "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/isContiguousUTF8",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SS16isContiguousUTF8Sbvp"
  },
  "title" : "isContiguousUTF8"
}
-->

# isContiguousUTF8

Returns whether this string’s storage contains
validly-encoded UTF-8 contents in contiguous memory.

```
var isContiguousUTF8: Bool { get }
```

## Discussion

Contiguous strings always operate in O(1) time for withUTF8, always give
a result for String.UTF8View.withContiguousStorageIfAvailable, and always
return a non-nil value from `String._utf8Span` and `String.UTF8View._span`.
Contiguous strings also benefit from fast-paths and better optimizations.

---

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)