summaryrefslogtreecommitdiff
path: root/vendor/utfcpp/utf8/unchecked.h
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/utfcpp/utf8/unchecked.h')
-rw-r--r--vendor/utfcpp/utf8/unchecked.h29
1 files changed, 15 insertions, 14 deletions
diff --git a/vendor/utfcpp/utf8/unchecked.h b/vendor/utfcpp/utf8/unchecked.h
index cb2427166..c78419f69 100644
--- a/vendor/utfcpp/utf8/unchecked.h
+++ b/vendor/utfcpp/utf8/unchecked.h
@@ -38,7 +38,7 @@ namespace utf8
octet_iterator append(uint32_t cp, octet_iterator result)
{
if (cp < 0x80) // one octet
- *(result++) = static_cast<uint8_t>(cp);
+ *(result++) = static_cast<uint8_t>(cp);
else if (cp < 0x800) { // two octets
*(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
@@ -85,13 +85,13 @@ namespace utf8
break;
}
++it;
- return cp;
+ return cp;
}
template <typename octet_iterator>
uint32_t peek_next(octet_iterator it)
{
- return utf8::unchecked::next(it);
+ return utf8::unchecked::next(it);
}
template <typename octet_iterator>
@@ -102,18 +102,19 @@ namespace utf8
return utf8::unchecked::next(temp);
}
- // Deprecated in versions that include prior, but only for the sake of consistency (see utf8::previous)
- template <typename octet_iterator>
- inline uint32_t previous(octet_iterator& it)
- {
- return utf8::unchecked::prior(it);
- }
-
template <typename octet_iterator, typename distance_type>
void advance (octet_iterator& it, distance_type n)
{
- for (distance_type i = 0; i < n; ++i)
- utf8::unchecked::next(it);
+ const distance_type zero(0);
+ if (n < zero) {
+ // backward
+ for (distance_type i = n; i < zero; ++i)
+ utf8::unchecked::prior(it);
+ } else {
+ // forward
+ for (distance_type i = zero; i < n; ++i)
+ utf8::unchecked::next(it);
+ }
}
template <typename octet_iterator>
@@ -128,7 +129,7 @@ namespace utf8
template <typename u16bit_iterator, typename octet_iterator>
octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
- {
+ {
while (start != end) {
uint32_t cp = utf8::internal::mask16(*start++);
// Take care of surrogate pairs first
@@ -138,7 +139,7 @@ namespace utf8
}
result = utf8::unchecked::append(cp, result);
}
- return result;
+ return result;
}
template <typename u16bit_iterator, typename octet_iterator>