Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gltfpack: Use UTF-8 encoding during gltfpack processing #769

Merged
merged 2 commits into from
Sep 14, 2024
Merged

Conversation

zeux
Copy link
Owner

@zeux zeux commented Sep 14, 2024

When main() is used, the inputs are ANSI according to the current code page; this is fine if the file paths can be converted to ANSI, but may fail to open some files and will use ANSI file paths inside .gltf files which violates glTF specification.

This can be worked around by using UTF8 as ANSI code page via a manifest; however, to avoid having to bundle a manifest we can also convert the command line arguments to UTF8 and set UTF8 as the codepage instead.

This requires Windows 10 1803; on earlier Windows versions setlocale should silently fail so this should be more or less equivalent to the previous code.

Fixes #767

When main() is used, the inputs are ANSI according to the current code
page; this is fine if the file paths can be converted to ANSI, but may
fail to open some files and will use ANSI file paths inside .gltf files
which violates glTF specification.

This can be worked around by using UTF8 as ANSI code page via a
manifest; however, to avoid having to bundle a manifest we can also
convert the command line arguments to UTF8 and set UTF8 as the codepage
instead.

This requires Windows 10 1803; on earlier Windows versions setlocale
should silently fail so this should be more or less equivalent to the
previous code.
@zeux
Copy link
Owner Author

zeux commented Sep 14, 2024

This can also be solved with a manifest (https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page) and a couple of changes in CMakeLists.txt it looks like; will test this tomorrow as an alternative.

@zeux zeux force-pushed the gltf-utf8 branch 2 times, most recently from cc8822d to 75b4a57 Compare September 14, 2024 06:08
Since CMake supports manifest files as sources, it's a little easier to
specify UTF-8 as the ANSI encoding via that; this is embedded into .exe
and is used for command line arguments as well so the rest of the code
just works.
@zeux zeux merged commit fc5c85e into master Sep 14, 2024
24 checks passed
@zeux zeux deleted the gltf-utf8 branch September 14, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gltfpack: UTF-8 encoding of glTF JSON on windows
1 participant