SurrogatePairAwareTextIterator.h [plain text]
#ifndef SurrogatePairAwareTextIterator_h
#define SurrogatePairAwareTextIterator_h
#include <wtf/unicode/CharacterNames.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class SurrogatePairAwareTextIterator {
public:
SurrogatePairAwareTextIterator(const UChar*, int currentCharacter, int lastCharacter, int endCharacter);
inline bool consume(UChar32& character, unsigned& clusterLength)
{
if (m_currentCharacter >= m_lastCharacter)
return false;
character = *m_characters;
clusterLength = 1;
if (character < HiraganaLetterSmallA)
return true;
return consumeSlowCase(character, clusterLength);
}
void advance(unsigned advanceLength)
{
m_characters += advanceLength;
m_currentCharacter += advanceLength;
}
int currentCharacter() const { return m_currentCharacter; }
const UChar* characters() const { return m_characters; }
private:
bool consumeSlowCase(UChar32&, unsigned&);
UChar32 normalizeVoicingMarks();
const UChar* m_characters;
int m_currentCharacter;
int m_lastCharacter;
int m_endCharacter;
};
}
#endif