#if defined(OS_WINDOWS) wchar* un_wstring_from_string(String utf8_string, Allocator alloc) { return un_wstring_from_cstring(un_string_to_cstring(utf8_string, un_allocator_get_temporary()), alloc); } wchar* un_wstring_from_cstring(u8 *utf8_string, Allocator alloc) { u32 error_code, buffer_size, wrote_chars; wchar *string_buffer; assert(utf8_string != NULL); buffer_size = MultiByteToWideChar( CP_UTF8, 0, // or MB_PRECOMPOSED (LPCCH)utf8_string, -1, NULL, 0 ); if (!buffer_size) { error_code = GetLastError(); switch (error_code) { case ERROR_NO_UNICODE_TRANSLATION: return NULL; break; default: assert(false); break; } return NULL; } string_buffer = un_memory_alloc(sizeof(wchar) * buffer_size, alloc); if (string_buffer == NULL) { return NULL; } wrote_chars = MultiByteToWideChar( CP_UTF8, 0, // or MB_PRECOMPOSED (LPCCH)utf8_string, -1, (LPWSTR)string_buffer, buffer_size ); assert(wrote_chars == buffer_size); return string_buffer; } #else wchar* un_wstring_from_string(String utf8_string, Allocator alloc) { UNUSED(utf8_string); UNUSED(alloc); __TRAP(); } wchar* un_wstring_from_cstring(u8 *utf8_string, Allocator alloc) { UNUSED(utf8_string); UNUSED(alloc); __TRAP(); } #endif