MCPcopy Create free account
hub / github.com/WheretIB/nullc / get_buffer_encoding

Function get_buffer_encoding

external/pugixml/pugixml.cpp:1028–1051  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1026 }
1027
1028 xml_encoding get_buffer_encoding(xml_encoding encoding, const void* contents, size_t size)
1029 {
1030 // replace wchar encoding with utf implementation
1031 if (encoding == encoding_wchar) return get_wchar_encoding();
1032
1033 // replace utf16 encoding with utf16 with specific endianness
1034 if (encoding == encoding_utf16) return is_little_endian() ? encoding_utf16_le : encoding_utf16_be;
1035
1036 // replace utf32 encoding with utf32 with specific endianness
1037 if (encoding == encoding_utf32) return is_little_endian() ? encoding_utf32_le : encoding_utf32_be;
1038
1039 // only do autodetection if no explicit encoding is requested
1040 if (encoding != encoding_auto) return encoding;
1041
1042 // skip encoding autodetection if input buffer is too small
1043 if (size < 4) return encoding_utf8;
1044
1045 // try to guess encoding (based on XML specification, Appendix F.1)
1046 const uint8_t* data = static_cast<const uint8_t*>(contents);
1047
1048 DMC_VOLATILE uint8_t d0 = data[0], d1 = data[1], d2 = data[2], d3 = data[3];
1049
1050 return guess_buffer_encoding(d0, d1, d2, d3);
1051 }
1052
1053 bool get_mutable_buffer(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable)
1054 {

Callers 1

load_buffer_implMethod · 0.85

Calls 3

get_wchar_encodingFunction · 0.85
is_little_endianFunction · 0.85
guess_buffer_encodingFunction · 0.85

Tested by

no test coverage detected