---
title: span
framework: swift
role: symbol
role_heading: Instance Property
path: swift/string/utf8view/span
---

# span

A span over the UTF8 code units that make up this string.

## Declaration

```swift
var span: Span<UTF8.CodeUnit> { get }
```

## Discussion

Discussion note: In the case of bridged UTF16 String instances (on Apple platforms,) this property transcodes the code units the first time it is called. The transcoded buffer is cached, and subsequent calls to span can reuse the buffer. Returns: a Span over the UTF8 code units of this String. Complexity: O(1) for native UTF8 Strings, amortized O(1) for bridged UTF16 Strings.
