Skip to content

Commit b9babc8

Browse files
committed
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 bdbd654 commit b9babc8

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
@@ -11,7 +11,12 @@ namespace fsbridge {
1111

1212
FILE *fopen(const fs::path& p, const char *mode)
1313
{
14+
#ifndef WIN32
1415
return ::fopen(p.string().c_str(), mode);
16+
#else
17+
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,wchar_t> utf8_cvt;
18+
return ::_wfopen(p.wstring().c_str(), utf8_cvt.from_bytes(mode).c_str());
19+
#endif
1520
}
1621

1722
#ifndef WIN32

0 commit comments

Comments
 (0)