我有一个实例std::u16string,是否可以将其传递c_str()给Win32 API LPCWSTR,而不需要任何转换?例如,我可以安全地执行此操作:
auto u16s = std::u16string(u"Hello");
::SetWindowTextW(hWnd, reinterpret_cast<LPCWSTR>(u16s.c_str()));
Run Code Online (Sandbox Code Playgroud)
更新后,MSDN说这里 wchar_t是UTF-16LE,而char16_t只是UTF-16,没有指定endian.是否可以安全地假设char16_t在Windows上也始终是UTF-16LE?或者那将是MSVC编译器特定的,因此如果我与GCC合作,它可能是UTF-32LE(或者可能是UTF-16BE)?