-
Notifications
You must be signed in to change notification settings - Fork 454
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 config "outputLogEncoding" #550
Conversation
Add a config item "outputEncoding" to set the encoding of messages from cmake's build command which are displayed in the output console.
This change is excellent!! The output codepage issues has been persistently troublesome almost from the very beginning. I've been unable to test and was never sure how to approach this problem. One think I am wondering is if there is the possibility to auto-detect the code page. I found that Windows exposes a Instead of trying to get them all down immediately, could you add a lookup that uses the |
Alternatively, you could try using this table I made from codepage number to names. Maybe iconv just supports it out-of-the box? That would be awesome, and changing the output encoding setting wouldn't ever be required. |
It seems "_CODEPAGE" is not exposed on my Windows 10.
But we can get current active code page by run cmd 'chcp' with no parameter.
Maybe we can try to run 'chcp', extract the codepage number, and translate it to encoding name for iconv-lite. PS. Is this table generated from this page. |
1. Change the default value of "outputEncoding" to "auto" 2. When "outputEncoding" is "auto" and platform is Windows, auto detect the default codepage of system by run cmd chcp. 3. Translate codepage number to encode name by CodePageTable. 4. If auto detect failed, user can still set this config manually.
That's annoying. This looks good! I may do some refactors after merging it, but it won't be a big hastle. Last question: Can you verify that the auto-detection works on your system? |
Yes, it works on my system. But I didn't test on other language system except mine. |
Problem is still here |
@Nim Can you please open a separate issue for this. It's easier to track that way :) |
This change try to fix a codepage problem mentioned in some issues, such as #518 , #267 , #245 and #153.
The output messages of cmake build command are garbled when the default system codepage is not utf8.
It is fixed by adding a user config item "outputEncoding" to set the character encoding of messages in the output console.
How to use
Results
How it works
This change introduces a new dependency iconv-lite.
The console programs emit text encoded with the default system codepage. This change uses iconv-lite to decode those text to utf8 , so they can be displayed correctly on output console. To decode, iconv-lite
needs to know the default system codepage which is given by user's config "outputEncoding".