#include <ustl.h>
Public Types | |
typedef iterator_traits< Iterator >::value_type | value_type |
typedef iterator_traits< Iterator >::difference_type | difference_type |
typedef iterator_traits< Iterator >::pointer | pointer |
typedef iterator_traits< Iterator >::reference | reference |
Public Member Functions | |
utf8in_iterator (const Iterator &is) | |
utf8in_iterator (const utf8in_iterator &i) | |
const Iterator & | base (void) const |
const utf8in_iterator & | operator= (const utf8in_iterator &i) |
WChar | operator * (void) const |
Steps to the next character and updates current returnable value. | |
utf8in_iterator & | operator++ (void) |
utf8in_iterator | operator++ (int) |
bool | operator== (const utf8in_iterator &i) const |
bool | operator< (const utf8in_iterator &i) const |
utf8in_iterator & | operator+= (size_t n) |
difference_type | operator- (const utf8in_iterator &i) const |
Returns the distance in characters (as opposed to the distance in bytes). |
For example, you can copy from ustl::string to ustl::vector<wchar_t> with copy (utf8in (str.begin()), utf8in (str.end()), back_inserter(wvect)); There is no error handling; if the reading frame slips you'll get extra characters, one for every misaligned byte. Although it is possible to skip to the start of the next character, that would result in omitting the misformatted character and the one after it, making it very difficult to detect by the user. It is better to write some strange characters and let the user know his file is corrupted. Another problem is overflow on bad encodings (like a 0xFF on the end of a string). This is checked through the end-of-string nul character, which will always be there as long as you are using the string class.