Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@liubing
Copy link
Contributor

@liubing liubing commented Jan 13, 2024

This PR tries to fix #2977.

The advantage of using _stat() function over GetFileAttributesA() API is that:

  • When SPDLOG_WCHAR_FILENAMES is not defined:
    -- If setlocale(LC_ALL, ".UTF8") is called before, then filename will be treated as UTF8 string, and this is the main use case for supporting UTF8 filenames with std::string under Windows.
    -- If setlocale(LC_ALL, ".UTF8") is not called before, then filename will be treated with the current code page (CP_ACP), just like the old behavior.
  • When SPDLOG_WCHAR_FILENAMES is defined, the behavior is the same as if GetFileAttributesW() was used.

@gabime gabime merged commit 8979f7f into gabime:v1.x Jan 13, 2024
@gabime
Copy link
Owner

gabime commented Jan 13, 2024

Thanks @liubing

gabime added a commit that referenced this pull request Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

details::os::path_exists(const std::string&) doesn't handle UTF8 filename correctly under Windows

2 participants