Accessing Code Points with Iterators
Code points within a given RWUString are accessed in forward or reverse order. You can access the beginning of a string using the RWUString::beginCodePointIterator() method. Use operator*() on an iterator positioned at RWUString::beginCodePointIterator() to return the first code point in the string.
You can access the end of a string using the RWUString::endCodePointIterator() method. An iterator positioned at RWUString::endCodePointIterator() references the location just after the last code point in the string. Attempts to reference the code point from an iterator positioned at RWUString::endCodePointIterator() throw an RWUException with status code RWUIndexOutOfBoundsError. (See Chapter 9 for a discussion of error handling in the Internationalization Module.) Similarly, attempts to advance an iterator beyond RWUString::endCodePointIterator() also throw the same type of exception.
For example, assuming str is a non-const RWUString, the following code iterates forward over all code points in the string:
 
for (RWUConstStringIterator it = str.beginCodePointIterator();
it != str.endCodePointIterator();
++it) {
// Do something with *it here
}
This code iterates backward over all code points in the string:
 
for (RWUConstStringIterator it = str.endCodePointIterator();
it != str.beginCodePointIterator(); ) {
--it;
// Do something with *it here
}