| 1493 | } |
| 1494 | |
| 1495 | FILE* ImFileOpen(const char* filename, const char* mode) |
| 1496 | { |
| 1497 | #if defined(_WIN32) && !defined(__CYGWIN__) |
| 1498 | // We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames. Converting both strings from UTF-8 to wchar format (using a single allocation, because we can) |
| 1499 | const int filename_wsize = ImTextCountCharsFromUtf8(filename, NULL) + 1; |
| 1500 | const int mode_wsize = ImTextCountCharsFromUtf8(mode, NULL) + 1; |
| 1501 | ImVector<ImWchar> buf; |
| 1502 | buf.resize(filename_wsize + mode_wsize); |
| 1503 | ImTextStrFromUtf8(&buf[0], filename_wsize, filename, NULL); |
| 1504 | ImTextStrFromUtf8(&buf[filename_wsize], mode_wsize, mode, NULL); |
| 1505 | return _wfopen((wchar_t*)&buf[0], (wchar_t*)&buf[filename_wsize]); |
| 1506 | #else |
| 1507 | return fopen(filename, mode); |
| 1508 | #endif |
| 1509 | } |
| 1510 | |
| 1511 | // Load file content into memory |
| 1512 | // Memory allocated with ImGui::MemAlloc(), must be freed by user using ImGui::MemFree() |
no test coverage detected