class Core::Text::UTF16CodepointIterator

Overview

Bidirectional iterator over the codepoints of a UTF-16 string. More…

#include <coreutfcodec.h>

class UTF16CodepointIterator
{
public:
    // construction

    UTF16CodepointIterator(UStringPtr text, int length, int position = 0);

    // methods

    int getLength() const;
    int getPosition() const;
    void setPosition(int newPosition);
    bool isStart() const;
    bool isEnd() const;
    uchar32 peekNext() const;
    uchar32 peekPrevious() const;
    uchar32 next();
    uchar32 previous();
};

Detailed Documentation

Bidirectional iterator over the codepoints of a UTF-16 string.

The position is given in UTF-16 code units and lies between codepoints. Unpaired surrogates are returned as individual codepoints.

Methods

uchar32 peekNext() const

Get codepoint after current position without advancing, 0 at end.

uchar32 peekPrevious() const

Get codepoint before current position without moving back, 0 at start.

uchar32 next()

Get codepoint after current position and advance behind it, 0 at end.

uchar32 previous()

Move back one codepoint and return it, 0 at start.