| 1143 | } |
| 1144 | |
| 1145 | template <typename opt_swap> bool convert_buffer_utf32(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, opt_swap) |
| 1146 | { |
| 1147 | const uint32_t* data = static_cast<const uint32_t*>(contents); |
| 1148 | size_t length = size / sizeof(uint32_t); |
| 1149 | |
| 1150 | // first pass: get length in wchar_t units |
| 1151 | out_length = utf_decoder<wchar_counter, opt_swap>::decode_utf32_block(data, length, 0); |
| 1152 | |
| 1153 | // allocate buffer of suitable length |
| 1154 | out_buffer = static_cast<char_t*>(global_allocate((out_length > 0 ? out_length : 1) * sizeof(char_t))); |
| 1155 | if (!out_buffer) return false; |
| 1156 | |
| 1157 | // second pass: convert utf32 input to wchar_t |
| 1158 | wchar_writer::value_type out_begin = reinterpret_cast<wchar_writer::value_type>(out_buffer); |
| 1159 | wchar_writer::value_type out_end = utf_decoder<wchar_writer, opt_swap>::decode_utf32_block(data, length, out_begin); |
| 1160 | |
| 1161 | assert(out_end == out_begin + out_length); |
| 1162 | (void)!out_end; |
| 1163 | |
| 1164 | return true; |
| 1165 | } |
| 1166 | |
| 1167 | bool convert_buffer(char_t*& out_buffer, size_t& out_length, xml_encoding encoding, const void* contents, size_t size, bool is_mutable) |
| 1168 | { |
no test coverage detected