-
Notifications
You must be signed in to change notification settings - Fork 242
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
Add UTF-8 filename support on Windows #788
Conversation
Related test changes in PR KhronosGroup/KTX-Software-CTS#8. |
Does the ktx suite never call, e.g, ktxTexture_CreateFromNamedFile? If it does, how is that working? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nice cleanup over the first version.
2e3286e
to
47ec46c
Compare
b468af1
to
b6c681e
Compare
We still have to resolve how to fix the library functions
What do you thing, @aqnuep? |
I don't know. I'd certainly prefer that to be handled separately as I wouldn't like to increase the scope of this change. Using I think having filename based APIs part of the KTX API was somewhat a bad design decision, but if anything I'd suggest supporting only UTF-8, or adding "W" suffixed versions for wide-string input, like the WinAPIs do. |
15c6526
to
cac283c
Compare
Yes. Let's do a separate commit.
Doesn't this happen only if the application is using the generic text macros (_TCHAR, etc.)?
Too late to change it now. I am leaning towards making the current functions accept utf-8 which they will transcode to UTF-16 on Windows and adding "W" suffixed versions on Windows only. The functions are very small so this is not a problem. Probably should add "_t" prefixed macros as well for Windows users. |
For the most part, yes, but there could be other implications. If you'd prefer to use UTF-16 on Windows and try to get things built with UNICODE, that's an option too, but this PR (which hopefully will pass CI now) is trying to use UTF-8 instead.
Adding support for UTF-8 file names passed through the |
I am looking at this code again with a view to using it in the legacy tools. It uses
(line 41 in platform_utils.h) would break things. It needs to use _tstring because in the _UNICODE case it would be receiving and needing to return Note that when compiling for the Windows Store, _UNICODE is automatically defined. Not that we have any need to do that, but people connected with vcpkg have tried to do it, and filed a bug, without realizing that command line tools are pointless for the Windows Store. |
Another question. In
Shouldn't we use |
This is a common question amongst people new to C++ move semantics. For such return statements is unnecessary (see e.g.: https://stackoverflow.com/questions/14856344/when-should-stdmove-be-used-on-a-function-return-value). |
Thanks for the education. Please respond to my question regarding _UNICODE and generic text functions. I see you removed the call to |
I apologize if my response sounded scoffing, that was certainly not my intent. When I first started using C++ move semantics I had that very same question.
Sorry, I missed that. So in the current form, with the UTF-8 based approach the use of I did not want to remove that code though in case someone wants to build e.g. the library only with
I'm not sure what part of the repo they are building for that purpose, so we can revisit at some point to also support a UTF-16 based path (i.e.
After some more elaborate testing, I noticed that changing the code page would leave you with a command prompt with that code page afterwards, and even if we'd reset it at exit you could have font/output changes temporarily that would be awkward. So I thought it's best to just leave the codepage as the user uses it. If the user uses a codepage that shows the unicode characters properly as it types it, then the output will also show it correctly. So the final solution will produce consistent output with the input and does not mess (temporarily or otherwise) with the codepage the users set for themselves. I hope that makes sense. |
Not at all.
Currently _UNICODE has no effect on library compilation. My current plan for supporting international file names via the I can't see any reason to support building the application stack with _UNICODE defined. It is a lot of work to make _UNICODE compiles work without, after the work you've just done, any benefit as far as I can see. Since neither the library nor the apps will need _UNICODE compilation, we should remove the code to avoid confusion.
They were building the legacy tools in a 4.2.x release. I would hope what you just implemented will work for a Windows Store app. I think only the library and the loadtest apps are relevant to the Windows Store. The latter are not currently included in release builds and are subject to the availability of GLon12 and VulkanOn12 for Store apps.
I thought it might be something like that.
There is something strange going on in the case of the legacy tool I am converting now. Without After exploring the settings of the PowerShell terminal app I could not find any way to set the code page myself. Maybe it has to be done through some PowerShell command or environment setting. Do you know? On the other hand, given the experience with |
Windows shells are really weird with their codepage + font selection combo. I, for example couldn't get Japanese characters show up if I used the UTF-8 codepage with the default font, only if I explicitly changed the codepage to a Japanese one. FYI, codepage selection can be performed using the |
Curiouser and curiouser. I manually set |
Fixes #781.