diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-10-13 19:54:40 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-10-13 21:07:23 +0100 |
| commit | eb0d03f437ebf4e6668c991c322f53f73b354562 (patch) | |
| tree | d7624a7f3d2aed73403ed505d677d1d2944fc64c /src | |
| parent | 894dd2e055098bca0edccd67534ce11526725cf4 (diff) | |
Use Pass as default policy for invalid utf8 avoid asserting on that
Diffstat (limited to 'src')
| -rw-r--r-- | src/utf8.hh | 6 | ||||
| -rw-r--r-- | src/utf8_iterator.hh | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/utf8.hh b/src/utf8.hh index 116c225e..20199030 100644 --- a/src/utf8.hh +++ b/src/utf8.hh @@ -107,7 +107,7 @@ struct Pass // returns the codepoint of the character whose first byte // is pointed by it -template<typename InvalidPolicy = utf8::InvalidPolicy::Assert, +template<typename InvalidPolicy = utf8::InvalidPolicy::Pass, typename Iterator> Codepoint codepoint(Iterator it, Iterator end) { @@ -146,7 +146,7 @@ Codepoint codepoint(Iterator it, Iterator end) return InvalidPolicy{}(byte); } -template<typename InvalidPolicy = utf8::InvalidPolicy::Assert> +template<typename InvalidPolicy = utf8::InvalidPolicy::Pass> ByteCount codepoint_size(char byte) { if (not (byte & 0x80)) // 0xxxxxxx @@ -160,7 +160,7 @@ ByteCount codepoint_size(char byte) else { InvalidPolicy{}(byte); - return -1; + return 1; } } diff --git a/src/utf8_iterator.hh b/src/utf8_iterator.hh index d2d8fa6a..1637fe2d 100644 --- a/src/utf8_iterator.hh +++ b/src/utf8_iterator.hh @@ -12,7 +12,7 @@ namespace utf8 // adapter for an iterator on bytes which permits to iterate // on unicode codepoints instead. template<typename Iterator, - typename InvalidPolicy = utf8::InvalidPolicy::Assert> + typename InvalidPolicy = utf8::InvalidPolicy::Pass> class iterator { public: @@ -140,7 +140,7 @@ private: 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) { return iterator<Iterator, InvalidPolicy>{std::move(it)}; |
