MCPcopy Create free account
hub / github.com/MyGUI/mygui / convert_buffer_utf32

Function convert_buffer_utf32

UnitTests/TestApp/pugixml.cpp:1406–1427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1404
1405template<typename opt_swap>
1406PUGI__FN bool convert_buffer_utf32(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, opt_swap)
1407{
1408 const uint32_t* data = static_cast<const uint32_t*>(contents);
1409 size_t length = size / sizeof(uint32_t);
1410
1411 // first pass: get length in wchar_t units
1412 out_length = utf_decoder<wchar_counter, opt_swap>::decode_utf32_block(data, length, 0);
1413
1414 // allocate buffer of suitable length
1415 out_buffer = static_cast<char_t*>(xml_memory::allocate((out_length > 0 ? out_length : 1) * sizeof(char_t)));
1416 if (!out_buffer)
1417 return false;
1418
1419 // second pass: convert utf32 input to wchar_t
1420 wchar_writer::value_type out_begin = reinterpret_cast<wchar_writer::value_type>(out_buffer);
1421 wchar_writer::value_type out_end = utf_decoder<wchar_writer, opt_swap>::decode_utf32_block(data, length, out_begin);
1422
1423 assert(out_end == out_begin + out_length);
1424 (void)!out_end;
1425
1426 return true;
1427}
1428
1429PUGI__FN bool convert_buffer_latin1(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size)
1430{

Callers 1

convert_bufferFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected