Minor additional cleanup in utf8.hh
This commit is contained in:
parent
ceafa5459a
commit
e601bd5fe8
27
src/utf8.hh
27
src/utf8.hh
|
@ -61,19 +61,6 @@ Iterator advance(Iterator it, const Iterator& end, CharCount d)
|
|||
return it;
|
||||
}
|
||||
|
||||
// returns the character count between begin and end
|
||||
template<typename Iterator>
|
||||
CharCount distance(Iterator begin, const Iterator& end)
|
||||
{
|
||||
CharCount dist = 0;
|
||||
while (begin != end)
|
||||
{
|
||||
if ((*begin++ & 0xC0) != 0x80)
|
||||
++dist;
|
||||
}
|
||||
return dist;
|
||||
}
|
||||
|
||||
// return true if it points to the first byte of a (either single or
|
||||
// multibyte) character
|
||||
inline bool is_character_start(char c)
|
||||
|
@ -81,6 +68,20 @@ inline bool is_character_start(char c)
|
|||
return (c & 0xC0) != 0x80;
|
||||
}
|
||||
|
||||
// returns the character count between begin and end
|
||||
template<typename Iterator>
|
||||
CharCount distance(Iterator begin, const Iterator& end)
|
||||
{
|
||||
CharCount dist = 0;
|
||||
|
||||
while (begin != end)
|
||||
{
|
||||
if (is_character_start(*begin++))
|
||||
++dist;
|
||||
}
|
||||
return dist;
|
||||
}
|
||||
|
||||
// returns an iterator to the first byte of the character it is into
|
||||
template<typename Iterator>
|
||||
Iterator character_start(Iterator it, const Iterator& begin)
|
||||
|
|
Loading…
Reference in New Issue
Block a user