I'm not sure if `s.toWString().c_str()` is safe and does not leave you with a dangling pointer, i.e. the `std::wstring` object and all it's allocated memory no longer exists when you call `WideCharToMultiByte`. It would be better to explicitly save the `std::wstring` in a local variable.