From 786522358706ab2bebba77cce38131d599b7e881 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 26 Feb 2013 14:05:51 +0100 Subject: [PATCH] Add utf8::character_start function --- src/utf8.hh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/utf8.hh b/src/utf8.hh index 1d26a7e2..7b247092 100644 --- a/src/utf8.hh +++ b/src/utf8.hh @@ -81,6 +81,15 @@ bool is_character_start(Iterator it) return (*it & 0xC0) != 0x80; } +// returns an iterator to the first byte of the character it is into +template +Iterator character_start(Iterator it) +{ + while (not is_character_start(it)) + --it; + return it; +} + namespace InvalidBytePolicy {