Use Pass as default policy for invalid utf8 avoid asserting on that
This commit is contained in:
parent
894dd2e055
commit
eb0d03f437
|
@ -107,7 +107,7 @@ struct Pass
|
||||||
|
|
||||||
// returns the codepoint of the character whose first byte
|
// returns the codepoint of the character whose first byte
|
||||||
// is pointed by it
|
// is pointed by it
|
||||||
template<typename InvalidPolicy = utf8::InvalidPolicy::Assert,
|
template<typename InvalidPolicy = utf8::InvalidPolicy::Pass,
|
||||||
typename Iterator>
|
typename Iterator>
|
||||||
Codepoint codepoint(Iterator it, Iterator end)
|
Codepoint codepoint(Iterator it, Iterator end)
|
||||||
{
|
{
|
||||||
|
@ -146,7 +146,7 @@ Codepoint codepoint(Iterator it, Iterator end)
|
||||||
return InvalidPolicy{}(byte);
|
return InvalidPolicy{}(byte);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename InvalidPolicy = utf8::InvalidPolicy::Assert>
|
template<typename InvalidPolicy = utf8::InvalidPolicy::Pass>
|
||||||
ByteCount codepoint_size(char byte)
|
ByteCount codepoint_size(char byte)
|
||||||
{
|
{
|
||||||
if (not (byte & 0x80)) // 0xxxxxxx
|
if (not (byte & 0x80)) // 0xxxxxxx
|
||||||
|
@ -160,7 +160,7 @@ ByteCount codepoint_size(char byte)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
InvalidPolicy{}(byte);
|
InvalidPolicy{}(byte);
|
||||||
return -1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace utf8
|
||||||
// adapter for an iterator on bytes which permits to iterate
|
// adapter for an iterator on bytes which permits to iterate
|
||||||
// on unicode codepoints instead.
|
// on unicode codepoints instead.
|
||||||
template<typename Iterator,
|
template<typename Iterator,
|
||||||
typename InvalidPolicy = utf8::InvalidPolicy::Assert>
|
typename InvalidPolicy = utf8::InvalidPolicy::Pass>
|
||||||
class iterator
|
class iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -140,7 +140,7 @@ private:
|
||||||
mutable Codepoint m_value = -1;
|
mutable Codepoint m_value = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename InvalidPolicy = utf8::InvalidPolicy::Assert, typename Iterator>
|
template<typename InvalidPolicy = utf8::InvalidPolicy::Pass, typename Iterator>
|
||||||
iterator<Iterator, InvalidPolicy> make_iterator(Iterator it)
|
iterator<Iterator, InvalidPolicy> make_iterator(Iterator it)
|
||||||
{
|
{
|
||||||
return iterator<Iterator, InvalidPolicy>{std::move(it)};
|
return iterator<Iterator, InvalidPolicy>{std::move(it)};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user