xref: /aosp_15_r20/external/grpc-grpc/third_party/utf8_range/boost.cpp (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1 #include <boost/locale.hpp>
2 
3 using namespace std;
4 
5 /* Return 0 on sucess, -1 on error */
utf8_boost(const unsigned char * data,int len)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 }
16