CodeUnits class sealed

A platform-agnostic view over a sequence of path code units.

pathify stores POSIX paths as Uint8List (each element is a single byte of the encoded path) and Windows paths as Uint16List (each element is one UTF-16 code unit). CodeUnits is the abstraction that lets internal code — the components iterator, the prefix parser, the extension splitter — read and slice path content without losing information for non-ASCII code units.

The crucial property: every operation here preserves the original code unit values. ASCII bytes (separators, dots, drive letters, ?, UNC) compare correctly because their values are identical in both representations. Non-ASCII code units (UTF-16 surrogates, non-ASCII UTF-8 bytes) are carried through verbatim and never truncated.

Slicing produces a new CodeUnits that shares storage with the original — it never copies. Materializing via toTypedData returns the underlying buffer in its original type.

To choose a representation:

Implementers

Constructors

CodeUnits.from(TypedData buf)
Wraps any supported TypedData without copying.
factory
CodeUnits.fromUint8List(Uint8List buf)
Wraps a Uint8List without copying.
factory
CodeUnits.fromUint16List(Uint16List buf)
Wraps a Uint16List without copying.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
True when length is zero.
no setter
isNarrow bool
True when this view is backed by a Uint8List.
no setter
isNotEmpty bool
True when length is non-zero.
no setter
isWide bool
True when this view is backed by a Uint16List.
no setter
length int
The number of code units in this view.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

appendCodeUnit(int unit) CodeUnits
Builds a new CodeUnits of the same width with unit appended, allocating a fresh buffer.
clone() CodeUnits
Materializes this view as a fresh, non-shared buffer of the same type and width.
concat(CodeUnits other) CodeUnits
Concatenates other onto this view, allocating a fresh buffer.
emptyOfSameWidth() CodeUnits
Builds an empty CodeUnits of the same width as this one.
equalsCodeUnits(CodeUnits other) bool
Compares two CodeUnits views for element-wise equality.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sublistView(int start, [int? end]) CodeUnits
Returns a view over the range [start, end) (or [start, length) when end is omitted) without copying.
toString() String
A string representation of this object.
inherited
toTypedData() TypedData
Returns the underlying buffer as a TypedData.

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](int index) int
Reads the code unit at index.