3 #include "utf8/checked.h"
5 #include "utf8/unchecked.h"
6 #include <websocketpp/utf8_validator.hpp>
16 return utf8::is_valid( str.begin(), str.end() );
22 auto itr = utf8::find_invalid(str.begin(), str.end());
23 if( itr == str.end() )
return str;
25 result = string( str.begin(), itr );
26 while( itr != str.end() ) {
29 itr = utf8::find_invalid( start, str.end());
30 result += string( start, itr );
35 void decodeUtf8(
const std::string& input, std::wstring* storage)
37 assert(storage !=
nullptr);
39 utf8::utf8to32(input.begin(), input.end(), std::back_inserter(*storage));
42 void encodeUtf8(
const std::wstring& input, std::string* storage)
44 assert(storage !=
nullptr);
46 utf8::utf32to8(input.begin(), input.end(), std::back_inserter(*storage));