12 #ifndef OGLPLUS_STRING_UTF8_1102101236_HPP
13 #define OGLPLUS_STRING_UTF8_1102101236_HPP
15 #include <oglplus/config/compiler.hpp>
23 typedef char32_t UnicodeCP;
25 std::size_t UTF8BytesRequired(
const UnicodeCP* cp_str, std::size_t len);
27 void ConvertCodePointToUTF8(UnicodeCP cp,
char* str, std::size_t& len);
29 void ConvertCodePointsToUTF8(
32 std::vector<char>& result
35 std::size_t CodePointsRequired(
const char* str, std::size_t len);
37 UnicodeCP ConvertUTF8ToCodePoint(
43 void ConvertUTF8ToCodePoints(
46 std::vector<UnicodeCP>& result
52 static bool _is_valid_ptr(
const char* _s);
53 static unsigned char byte(
const char* _i);
56 static void _check_seq_tail(
const char* _s)
58 for(
int i=1; i!=N; ++i)
60 assert(byte(_s) != 0x00);
61 assert(byte(_s) != 0x80);
67 static const char* _validate(
const char* _s,
const char* _end);
69 bool operator()(
const char* begin,
const char* end)
const
71 return _validate(begin, end) == end;
75 inline bool ValidUTF8(
const char* begin,
const char* end)
77 #if !OGLPLUS_NO_UTF8_CHECKS
78 UTF8Validator valid_utf8;
79 return valid_utf8(begin, end);
81 OGLPLUS_FAKE_USE(begin);
82 OGLPLUS_FAKE_USE(end);
90 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
91 #include <oglplus/string/utf8.ipp>
92 #endif // OGLPLUS_LINK_LIB