diff --git a/source/utf8/checked.h b/source/utf8/checked.h index dc342ff..5670c19 100644 --- a/source/utf8/checked.h +++ b/source/utf8/checked.h @@ -152,6 +152,12 @@ namespace utf8 return cp; } + template + uint32_t peek_next(octet_iterator it, octet_iterator end) + { + return next(it, end); + } + template uint32_t prior(octet_iterator& it, octet_iterator start) { diff --git a/source/utf8/unchecked.h b/source/utf8/unchecked.h index 2277d28..4009ceb 100644 --- a/source/utf8/unchecked.h +++ b/source/utf8/unchecked.h @@ -56,6 +56,7 @@ namespace utf8 } return result; } + template uint32_t next(octet_iterator& it) { @@ -87,6 +88,12 @@ namespace utf8 return cp; } + template + uint32_t peek_next(octet_iterator it) + { + return next(it); + } + template uint32_t prior(octet_iterator& it) { diff --git a/test_drivers/smoke_test/test.cpp b/test_drivers/smoke_test/test.cpp index c50e136..f454549 100644 --- a/test_drivers/smoke_test/test.cpp +++ b/test_drivers/smoke_test/test.cpp @@ -22,7 +22,6 @@ int main() end = append(0x10346, u); assert (u[0] == 0xf0 && u[1] == 0x90 && u[2] == 0x8d && u[3] == 0x86 && u[4] == 0); - //next char* twochars = "\xe6\x97\xa5\xd1\x88"; @@ -43,6 +42,12 @@ int main() assert (cp == 0x0448); assert (w == threechars + 9); + //peek_next + char* const cw = twochars; + cp = peek_next(cw, cw + 6); + assert (cp == 0x65e5); + assert (cw == twochars); + //prior w = twochars + 3; cp = prior (w, twochars); @@ -197,6 +202,11 @@ int main() assert (cp == 0x0448); assert (w == threechars + 9); + //peek_next + cp = unchecked::peek_next(cw); + assert (cp == 0x65e5); + assert (cw == twochars); + //previous (calls prior internally)