More portable OsString conversion methods, for paths #27657
Closed
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.
Existing code-bases often store paths in a platform specific way. For example, 'git' follows the unix convention of accepting arbitrary byte sequences as paths, while windows-only code tends to use TCHAR* or WCHAR* exclusively. Each is fundamentally incapable of storing every possible path on the other platform.
The need arises to be able to interoperate with these libraries without enforcing additional constraints on the paths (for example, it may be necessary to accept invalid utf8 in paths on linux). The existing methods to convert to and from OsStrings are poorly named, only cater to the linux use-case, and additionally have a failure mode which can only occur on windows, resulting in a particularly poor compatibility story on windows.
See #27390 for a very long argument between @alexcrichton and myself on the matter, and why I think this is the best approach to take.