Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also use _stat() on Windows to be more UTF8 friendly #2978

Merged
merged 2 commits into from
Jan 13, 2024

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
8 checks passed
@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