Update vendored utfcpp to v3.1.

This commit is contained in:
Peter Powell 2019-08-02 12:52:22 +01:00
parent cb1e9772a9
commit 4f4bc07f41
2 changed files with 42 additions and 2 deletions

2
vendor/README.md vendored
View File

@ -36,7 +36,7 @@ This directory contains vendored dependencies that are shipped with InspIRCd to
**Author** — Nemanja Trifunovic
**Last Updated** — 2019-04-25 (ad27c7d5e0e5b4c3baca4a2e70c0336b68c0dffb)
**Last Updated** — 2019-08-02 (v3.1)
**License** — Boost Software License

View File

@ -32,7 +32,7 @@ DEALINGS IN THE SOFTWARE.
namespace utf8
{
namespace unchecked
namespace unchecked
{
template <typename octet_iterator>
octet_iterator append(uint32_t cp, octet_iterator result)
@ -57,6 +57,46 @@ namespace utf8
return result;
}
template <typename octet_iterator, typename output_iterator>
output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement)
{
while (start != end) {
octet_iterator sequence_start = start;
internal::utf_error err_code = utf8::internal::validate_next(start, end);
switch (err_code) {
case internal::UTF8_OK :
for (octet_iterator it = sequence_start; it != start; ++it)
*out++ = *it;
break;
case internal::NOT_ENOUGH_ROOM:
out = utf8::unchecked::append (replacement, out);
start = end;
break;
case internal::INVALID_LEAD:
out = utf8::unchecked::append (replacement, out);
++start;
break;
case internal::INCOMPLETE_SEQUENCE:
case internal::OVERLONG_SEQUENCE:
case internal::INVALID_CODE_POINT:
out = utf8::unchecked::append (replacement, out);
++start;
// just one replacement mark for the sequence
while (start != end && utf8::internal::is_trail(*start))
++start;
break;
}
}
return out;
}
template <typename octet_iterator, typename output_iterator>
inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out)
{
static const uint32_t replacement_marker = utf8::internal::mask16(0xfffd);
return utf8::unchecked::replace_invalid(start, end, out, replacement_marker);
}
template <typename octet_iterator>
uint32_t next(octet_iterator& it)
{