| 106 | |
| 107 | template <typename CHAR_TYPE> |
| 108 | inline void WcsToUtf8(const void* wcs_string, size_t length_in_code_units, |
| 109 | std::vector<uint8_t>* result) { |
| 110 | const auto* begin = static_cast<const CHAR_TYPE*>(wcs_string); |
| 111 | |
| 112 | std::string string; |
| 113 | if constexpr (sizeof(CHAR_TYPE) == sizeof(char16_t)) { |
| 114 | ::utf8::utf16to8(begin, begin + length_in_code_units, std::back_inserter(string)); |
| 115 | } else { |
| 116 | static_assert(sizeof(CHAR_TYPE) == sizeof(char32_t)); |
| 117 | ::utf8::utf32to8(begin, begin + length_in_code_units, std::back_inserter(string)); |
| 118 | } |
| 119 | |
| 120 | result->assign(string.begin(), string.end()); |
| 121 | } |
| 122 | |
| 123 | inline void WcsToUtf8(const void* wcs_string, size_t length_in_code_units, |
| 124 | std::vector<uint8_t>* result) { |
no test coverage detected