Skip to content

Can't use Scene::saveToFile() with UTF-8-based string data on Windows #60

@ParadoxDaKo

Description

@ParadoxDaKo

Ramses Version: 27.0.115

For file paths, we are using UTF-8-based strings to support non-ASCII data such as Umlauts or Chinese letters.

Scene::saveToFile() accepts a const char* fileName and essentially passes it to fopen without change/encoding.

A simple const char* literal containing umlauts contains different data as a UTF-8 string with the same umlauts that gets its data passed into a const char* - which fopen doesn't seem to handle properly on Windows systems.

Here is a GTest that elucidates the problem:

TEST(ramses, saveToFile_withUmlauts) {
    ramses::RamsesFramework ramsesFramework;
    ramses::RamsesClient& client = *ramsesFramework.createClient("example client");
    ramses::Scene* scene = client.createScene(ramses::sceneId_t(123u), ramses::SceneConfig(), "export scene");

    std::filesystem::path path("saveToFile_äöü.ramses");	
    auto status = scene->saveToFile(path.generic_u8string().c_str(), false);

    ASSERT_EQ(status, 0);
}

In this test case, Ramses would try and save a file with the filename saveToFile_äöü.ramses.

PS: Even const char* literals with Chinese letters don't work with Scene::saveToFile().

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions