diff --git a/tiny_gltf.h b/tiny_gltf.h index e84725a..f9ef35d 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -7208,7 +7208,9 @@ static void WriteBinaryGltfFile(const std::string &output, #if defined(_MSC_VER) std::ofstream gltfFile(UTF8ToWchar(output).c_str(), std::ios::binary); #elif defined(__GLIBCXX__) - std::ofstream gltfFile(output.c_str(), std::ios::binary); + int file_descriptor = _wopen(UTF8ToWchar(output).c_str(), _O_WRONLY | _O_BINARY); + __gnu_cxx::stdio_filebuf wfile_buf(file_descriptor, std::ios_base::in); + std::ostream gltfFile(&wfile_buf); #else std::ofstream gltfFile(output.c_str(), std::ios::binary); #endif