summaryrefslogtreecommitdiff
path: root/src/utf8.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-09-23 22:09:37 +0100
committerMaxime Coste <frrrwww@gmail.com>2015-09-23 22:09:37 +0100
commite601bd5fe8cc6525b45cd243462cd093281843d7 (patch)
treec457720be27121c42d0bb9963c188622a07657f1 /src/utf8.hh
parentceafa5459ad5ff5d83d2a767f011f7acfa7f37cd (diff)
Minor additional cleanup in utf8.hh
Diffstat (limited to 'src/utf8.hh')
-rw-r--r--src/utf8.hh17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/utf8.hh b/src/utf8.hh
index dd7974e7..545255fd 100644
--- a/src/utf8.hh
+++ b/src/utf8.hh
@@ -61,26 +61,27 @@ Iterator advance(Iterator it, const Iterator& end, CharCount d)
return it;
}
+// return true if it points to the first byte of a (either single or
+// multibyte) character
+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 ((*begin++ & 0xC0) != 0x80)
+ if (is_character_start(*begin++))
++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)
-{
- return (c & 0xC0) != 0x80;
-}
-
// returns an iterator to the first byte of the character it is into
template<typename Iterator>
Iterator character_start(Iterator it, const Iterator& begin)