You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fixes Unicode paths on Windows
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 <[email protected]>
* Moved UNICODE and _UNICODE definitions to CMake
Signed-off-by: itsmattkc <[email protected]>
* handle empty strings and use const references
Signed-off-by: itsmattkc <[email protected]>
* only use wenviron when unicode is enabled
Signed-off-by: itsmattkc <[email protected]>
* add ANSI Win32 version of Getenv
Signed-off-by: itsmattkc <[email protected]>
* Add CMake option for compiling with Win32 Unicode support
Signed-off-by: itsmattkc <[email protected]>
* Throw exception if UTF functions are called on non-Windows platforms
Signed-off-by: itsmattkc <[email protected]>
* Throw OCIO Exception
Signed-off-by: itsmattkc <[email protected]>
* Don't run UTF-8/16 conversion test on non-Windows
Signed-off-by: itsmattkc <[email protected]>
* Fix CMake error
Signed-off-by: itsmattkc <[email protected]>
* minor CMake adjustment
Signed-off-by: itsmattkc <[email protected]>
* Clarified CMake option for Win32 unicode
Signed-off-by: itsmattkc <[email protected]>
* minor improvements
Signed-off-by: itsmattkc <[email protected]>
* fix macro in cpu test cmake
Signed-off-by: itsmattkc <[email protected]>
Co-authored-by: itsmattkc <[email protected]>
0 commit comments