Utf8Iterator Class Reference

#include <Pt/Utf8.h>

UTF-8 string input iterator. More...

Public Member Functions

 Utf8Iterator ()
 Construct end iterator.
 
 Utf8Iterator (const char *utf8, std::size_t n)
 Construct from UTF-8 string data.
 
 Utf8Iterator (const std::string &bytes)
 Construct from UTF-8 encoded string.
 
 Utf8Iterator (const Utf8Iterator &other)
 Copy constructor.
 
bool operator!= (const Utf8Iterator &other) const
 Inequality comparison.
 
const Charoperator* () const
 Returns current character.
 
Utf8Iteratoroperator++ ()
 Decodes next character.
 
Utf8Iterator operator++ (int)
 Decodes next character.
 
Utf8Iteratoroperator= (const Utf8Iterator &other)
 Assignment operator.
 
bool operator== (const Utf8Iterator &other) const
 Equality comparison.
 

Detailed Description

The Utf8Iterator is a read-only input iterator, to iterate an UTF-8 string as if it were a sequence of unicode characters. When used with standard C++ algorithms, the default constructed iterator serves as an iterator pointing to the end of the logic sequence.

std::string utf8 = "Hell\303\266 W\303\266rld!";
Char oe = 0366;
int n = std::count(it, end, oe);
assert(n == 2);