MCPcopy Create free account
hub / github.com/Aloshi/EmulationStation / convert_buffer_utf8

Function convert_buffer_utf8

src/pugiXML/pugixml.cpp:1206–1225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

convert_bufferFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected