I use a function from the Windows API called GetFileAttributesW to retrieve attributes from a file. The function signature is defined as:
DWORD GetFileAttributesW([in] LPCWSTR lpFileName);
LPCWSTR is defined as const wchar_t*.
I want to call the function:
fs::path inputPath = ...
GetFileAttributesW(inputPath.whichMethodHere()?);
The given input path is of type std::filesystem::path that has several convenience converters like:
std::filesystem::path::string()
std::filesystem::path::wstring()
std::filesystem::path::u8string()
std::filesystem::path::u16string()
std::filesystem::path::u32string()
The two functions wstring() and u16string() stand out here for me. Both are defined with a character type of wchar_t and char16_t respectively.
Question 1:
What is the main difference between wstring() and u16string(). Does wstring() return something different than u16string in real life scenarios?
Question 2:
Which encoding does the Windows API generally expect?