MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenImageIO / convert_buffer_utf8

Function convert_buffer_utf8

src/include/pugixml.cpp:1208–1227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1206 }
1207
1208 PUGI__FN bool convert_buffer_utf8(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size)
1209 {
1210 const uint8_t* data = static_cast<const uint8_t*>(contents);
1211
1212 // first pass: get length in wchar_t units
1213 out_length = utf_decoder<wchar_counter>::decode_utf8_block(data, size, 0);
1214
1215 // allocate buffer of suitable length
1216 out_buffer = static_cast<char_t*>(xml_memory::allocate((out_length > 0 ? out_length : 1) * sizeof(char_t)));
1217 if (!out_buffer) return false;
1218
1219 // second pass: convert utf8 input to wchar_t
1220 wchar_writer::value_type out_begin = reinterpret_cast<wchar_writer::value_type>(out_buffer);
1221 wchar_writer::value_type out_end = utf_decoder<wchar_writer>::decode_utf8_block(data, size, out_begin);
1222
1223 assert(out_end == out_begin + out_length);
1224 (void)!out_end;
1225
1226 return true;
1227 }
1228
1229 template <typename opt_swap> PUGI__FN bool convert_buffer_utf16(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, opt_swap)
1230 {

Callers 1

convert_bufferFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected