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

Method decode_utf16_block

Tools/EditorFramework/pugixml.cpp:1016–1061  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1014 }
1015
1016 static inline typename Traits::value_type decode_utf16_block(
1017 const uint16_t* data,
1018 size_t size,
1019 typename Traits::value_type result)
1020 {
1021 const uint16_t* end = data + size;
1022
1023 while (data < end)
1024 {
1025 uint16_t lead = opt_swap::value ? endian_swap(*data) : *data;
1026
1027 // U+0000..U+D7FF
1028 if (lead < 0xD800)
1029 {
1030 result = Traits::low(result, lead);
1031 data += 1;
1032 }
1033 // U+E000..U+FFFF
1034 else if (static_cast<unsigned int>(lead - 0xE000) < 0x2000)
1035 {
1036 result = Traits::low(result, lead);
1037 data += 1;
1038 }
1039 // surrogate pair lead
1040 else if (static_cast<unsigned int>(lead - 0xD800) < 0x400 && data + 1 < end)
1041 {
1042 uint16_t next = opt_swap::value ? endian_swap(data[1]) : data[1];
1043
1044 if (static_cast<unsigned int>(next - 0xDC00) < 0x400)
1045 {
1046 result = Traits::high(result, 0x10000 + ((lead & 0x3ff) << 10) + (next & 0x3ff));
1047 data += 2;
1048 }
1049 else
1050 {
1051 data += 1;
1052 }
1053 }
1054 else
1055 {
1056 data += 1;
1057 }
1058 }
1059
1060 return result;
1061 }
1062
1063 static inline typename Traits::value_type decode_utf32_block(
1064 const uint32_t* data,

Callers

nothing calls this directly

Calls 1

endian_swapFunction · 0.70

Tested by

no test coverage detected