Iterating Over Strings
The Internationalization Module provides standard iterators that represent a location within an
RWUString, and provides access to the code point at that location:
RWUStringIterator provides read-write access to the code points encoded by the code units within an
RWUString.
RWUConstStringIterator provides read-only access to the code points encoded by the code units within an
RWUString.
RWUStringIterator instances are returned from non-const
RWUString objects.
RWUConstStringIterator instances are returned from const
RWUString objects, and from instances of classes such as
RWUBreakSearch (
Chapter 7). These classes return
RWUConstStringIterator instances to prevent the
RWUString from being changed during processing.
You can construct an
RWUConstStringIterator from a given
RWUStringIterator, but there is no corresponding conversion from
RWUConstStringIterator to
RWUStringIterator. This preserves
const correctness for the iterator classes.
NOTE: To iterate over the code units in an RWUString, you can use the operator[] interface inherited from RWBasicUString.