-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unlike most other platforms, Windows' Unicode is standardized around UTF-16, an encoding not compatible with "char *" arrays common in C/C++. As such, to support Unicode correctly when using Win32 APIs, strings must be converted to and from UTF-16 and the Unicode versions of the APIs must be used over the ANSI versions. This commit introduces the following: - Utility funcions for converting between UTF-8 and UTF-16LE on all platforms: - Platform::Utf8ToUtf16 - Platform::Utf16ToUtf8 - Adds test for these conversion functions to ensure the conversion to and from UTF-8 and UTF-16LE is correct. - Utility wrappers for "std::ifstream" that automatically convert to and from UTF-16 so that filenames requiring Unicode encoding function correctly: - Platform::CreateInputFileStream - Platform::OpenInputFileStream - Moves the file default compute hash function to the Platform class (Platform::CreateFileContentHash) and switches to the Win32 UTF-16 variant on Windows. - Adds the "UNICODE" macro before including "Windows.h" which ensures all functions called are the Unicode variants instead of the default ANSI variants. - Implicitly changes functions such as GetEnvironmentVariable and SetEnvironmentVariable to their Unicode variants. - Changes the following environment variable related functions to their Win32 Unicode variants on Windows: - environ -> _wenviron - _putenv_s -> _wputenv_s - Updates tests using SetEnvironmentVariable to use wide string literals since that function has been switched to the Unicode variant. Signed-off-by: itsmattkc <itsmattkc@gmail.com>
- Loading branch information
Showing
10 changed files
with
254 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.