Hi!
I am encountering issues when trying to open a stage from a path containing UTF-8 chars and I am running out of ideas of what the root cause is.
I am on Windows. The code scheme:
std::wstring Utf8ToWString(const std::string& utf8Str)
{
int size_needed = MultiByteToWideChar(CP_UTF8, 0, utf8Str.c_str(), -1, NULL, 0);
std::wstring wstr(size_needed, 0);
MultiByteToWideChar(CP_UTF8, 0, utf8Str.c_str(), -1, &wstr[0], size_needed);
return wstr;
}
void openStage(const std::string& inputScenePath)
{
if (std::filesystem::exists(Utf8ToWString(inputScenePath)))
{
std::cout << "File exists!\n";
}
UsdStageRefPtr stage = UsdStage::Open(inputScenePath);
if (!stage)
{
throw std::runtime_error("Failed to open USD file");
}
}
When inputScenePath
contains ASCII chars only then the code works properly.
As soon as the path contains a non-standard UTF-8 character, its existence is detected properly (the app outputs File Exists) but the Open method returns an error: The system cannot find the file specified.
Any ideas about how to solve it?