Skip to content

Commit dd94241

Browse files
ken2812221furszy
authored andcommitted
utils: Use _wfopen and _wreopen on Windows
The fopen function does not support unicode filename on Windows, so use Windows specific function do deal with it
1 parent 3993641 commit dd94241

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/fs.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ namespace fsbridge {
1616

1717
FILE *fopen(const fs::path& p, const char *mode)
1818
{
19+
#ifndef WIN32
1920
return ::fopen(p.string().c_str(), mode);
21+
#else
22+
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,wchar_t> utf8_cvt;
23+
return ::_wfopen(p.wstring().c_str(), utf8_cvt.from_bytes(mode).c_str());
24+
#endif
2025
}
2126

2227

0 commit comments

Comments
 (0)