Contents

isContiguousUTF8

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

Declaration

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.

See Also

Working with Encodings