MCPcopy Create free account
hub / github.com/Aloshi/EmulationStation / xml_encoding get_buffer_encoding

Function xml_encoding get_buffer_encoding

src/pugiXML/pugixml.cpp:1132–1155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1130 }
1131
1132 PUGI__FN xml_encoding get_buffer_encoding(xml_encoding encoding, const void* contents, size_t size)
1133 {
1134 // replace wchar encoding with utf implementation
1135 if (encoding == encoding_wchar) return get_wchar_encoding();
1136
1137 // replace utf16 encoding with utf16 with specific endianness
1138 if (encoding == encoding_utf16) return is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
1139
1140 // replace utf32 encoding with utf32 with specific endianness
1141 if (encoding == encoding_utf32) return is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
1142
1143 // only do autodetection if no explicit encoding is requested
1144 if (encoding != encoding_auto) return encoding;
1145
1146 // skip encoding autodetection if input buffer is too small
1147 if (size < 4) return encoding_utf8;
1148
1149 // try to guess encoding (based on XML specification, Appendix F.1)
1150 const uint8_t* data = static_cast<const uint8_t*>(contents);
1151
1152 PUGI__DMC_VOLATILE uint8_t d0 = data[0], d1 = data[1], d2 = data[2], d3 = data[3];
1153
1154 return guess_buffer_encoding(d0, d1, d2, d3);
1155 }
1156
1157 PUGI__FN bool get_mutable_buffer(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable)
1158 {

Callers

nothing calls this directly

Calls 1

is_little_endianFunction · 0.85

Tested by

no test coverage detected