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

Function convert_buffer_utf32

src/include/pugixml.cpp:1251–1271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1249 }
1250
1251 template <typename opt_swap> PUGI__FN bool convert_buffer_utf32(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, opt_swap)
1252 {
1253 const uint32_t* data = static_cast<const uint32_t*>(contents);
1254 size_t length = size / sizeof(uint32_t);
1255
1256 // first pass: get length in wchar_t units
1257 out_length = utf_decoder<wchar_counter, opt_swap>::decode_utf32_block(data, length, 0);
1258
1259 // allocate buffer of suitable length
1260 out_buffer = static_cast<char_t*>(xml_memory::allocate((out_length > 0 ? out_length : 1) * sizeof(char_t)));
1261 if (!out_buffer) return false;
1262
1263 // second pass: convert utf32 input to wchar_t
1264 wchar_writer::value_type out_begin = reinterpret_cast<wchar_writer::value_type>(out_buffer);
1265 wchar_writer::value_type out_end = utf_decoder<wchar_writer, opt_swap>::decode_utf32_block(data, length, out_begin);
1266
1267 assert(out_end == out_begin + out_length);
1268 (void)!out_end;
1269
1270 return true;
1271 }
1272
1273 PUGI__FN bool convert_buffer_latin1(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size)
1274 {

Callers 1

convert_bufferFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected