Repository navigation
C++ 20: Use UTF-16 Paths and Resource URLs - #12327
Merged
Jon Thysell (jonthysell) merged 9 commits intoNov 7, 2023
Merged
Conversation
1. Both WinRT and std::filesystem use system-native UTF-16 paths on Windows. Defaulting to UTF16 lets us avoid conversion until needed, and fixes some instances of round-tripping between formats. 2. We rely on `path.u8string()` to return a Unicode representation of a path, but that API in C++ 20 returns `std::u8string` which is incompatible with every other existing utf-8 API. `path.string()` may convert to system codepage instead. 3. This makes coroutine usage more efficient when using `IAsyncOperation<winrt::hstring>`, the pattern to replace `std::future<std::string>` usage mechanically. `std::filesystem::path` internally uses Windows native UTF-16 path. We use `u8string()` to convert to UTF-8.
Nick Gerleman (NickGerleman)
marked this pull request as ready for review
November 1, 2023 10:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
path.u8string()to return a Unicode representation of a path, but that API in C++ 20 returnsstd::u8stringwhich is incompatible with every other existing utf-8 API.path.string()may convert to system codepage instead.IAsyncOperation<winrt::hstring>, the pattern to replacestd::future<std::string>usage mechanically.Microsoft Reviewers: Open in CodeFlow