Improve path conversions and add new string utilities#913
Merged
Conversation
- Rewrite to_charT_string_path() to properly handle UTF-8 and UTF-16 encodings - Add ensure_str_as<CharT>() for explicit target char type conversion - Add to_utf8_string() for UTF-8 string conversion - Add normalize_path_for_lua() to convert paths to UTF-8 with forward slashes - Add utf8_to_wpath() to convert UTF-8 paths to Windows wide strings BREAKING CHANGE: to_charT_string_path() now returns UTF-8 for char type instead of locale-dependent encoding
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.
Description
This PR enhances the string and path conversion utilities in the Helpers library with proper UTF-8 and UTF-16 support. The main improvements include rewriting the path conversion logic to handle Unicode correctly and adding several new utility functions for common string/path operations.
The key motivation is to ensure consistent and correct handling of Unicode paths across different platforms.
Necessary to be merged prior to #884
Type of change
How has this been tested?
Conversion tests/tested with updated lua system.
Checklist
Additional context
Breaking Change: The to_charT_string_path() function now returns UTF-8 encoded strings when the target type is char, instead of using locale-dependent encoding. This ensures consistent behavior across platforms but may affect code that relied on the previous locale-specific behavior, but I doubt there is any code that did.
New Functions Added:
ensure_str_as() - Allows explicit target character type conversion
to_utf8_string() - Convenient UTF-8 string conversion
normalize_path_for_lua() - Converts paths to UTF-8 with forward slashes for Lua compatibility
utf8_to_wpath() - Converts UTF-8 paths to Windows wide strings for API compatibility