extra/protobuf/protobuf-24.4/third_party/utf8_range/boost.cpp
raw| 1 | #include <boost/locale.hpp> |
| 2 | |
| 3 | using namespace std; |
| 4 | |
| 5 | /* Return 0 on sucess, -1 on error */ |
| 6 | extern "C" int utf8_boost(const unsigned char* data, int len) { |
| 7 | try { |
| 8 | boost::locale::conv::utf_to_utf<char>(data, data + len, |
| 9 | boost::locale::conv::stop); |
| 10 | } catch (const boost::locale::conv::conversion_error& ex) { |
| 11 | return -1; |
| 12 | } |
| 13 | |
| 14 | return 0; |
| 15 | } |