| 278 | private: |
| 279 | #if SC_PLATFORM_WINDOWS |
| 280 | bool appendUTF8ToNative(native_char_t* buffer, size_t capacity, size_t& numWritten) const |
| 281 | { |
| 282 | const char* it = bytesWithoutTerminator(); |
| 283 | const char* end = it + sizeInBytes(); |
| 284 | while (it < end) |
| 285 | { |
| 286 | uint32_t codePoint = 0; |
| 287 | if (not decodeUTF8(it, end, codePoint)) |
| 288 | return false; |
| 289 | if (codePoint <= 0xFFFF) |
| 290 | { |
| 291 | if (numWritten + 1 >= capacity) |
| 292 | return false; |
| 293 | buffer[numWritten++] = static_cast<wchar_t>(codePoint); |
| 294 | } |
| 295 | else |
| 296 | { |
| 297 | if (numWritten + 2 >= capacity) |
| 298 | return false; |
| 299 | codePoint -= 0x10000; |
| 300 | buffer[numWritten++] = static_cast<wchar_t>(0xD800u + (codePoint >> 10)); |
| 301 | buffer[numWritten++] = static_cast<wchar_t>(0xDC00u + (codePoint & 0x3FFu)); |
| 302 | } |
| 303 | } |
| 304 | buffer[numWritten] = L'\0'; |
| 305 | return true; |
| 306 | } |
| 307 | #endif |
| 308 | |
| 309 | static constexpr bool decodeUTF8(const char*& it, const char* end, uint32_t& codePoint) |
no test coverage detected