* WINDOWS function to convert wchar_t (utf16) strings to utf-8 strings. * Windows wchar_t is utf-16. * The calling function must check for errors and delete the * allocated memory. */
| 2637 | * allocated memory. |
| 2638 | */ |
| 2639 | char* ASLibrary::convertUtf16ToUtf8(const wchar_t* wcharIn) const |
| 2640 | { |
| 2641 | int utf8Len = WideCharToMultiByte(CP_UTF8, 0, wcharIn, -1, 0, 0, 0, 0); |
| 2642 | if (utf8Len == 0) |
| 2643 | return NULL; |
| 2644 | char* utf8 = new(nothrow) char[utf8Len]; |
| 2645 | if (utf8 == NULL) |
| 2646 | return NULL; |
| 2647 | WideCharToMultiByte(CP_UTF8, 0, wcharIn, -1, utf8, utf8Len, 0, 0); |
| 2648 | return utf8; |
| 2649 | } |
| 2650 | |
| 2651 | #else // not _WIN32 |
| 2652 |
nothing calls this directly
no outgoing calls
no test coverage detected