-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 Unicode support to CLI on Windows #8618
Conversation
Very nice! |
Codecov ReportBase: 64.25% // Head: 64.29% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #8618 +/- ##
===========================================
+ Coverage 64.25% 64.29% +0.04%
===========================================
Files 341 341
Lines 44330 44331 +1
===========================================
+ Hits 28483 28501 +18
+ Misses 15847 15830 -17
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
The coverage run failed because of an error in testcli, but it was in testAdd, which I didn't change, on Linux, where my changes to the CLI itself should be removed by the preprocessor. |
Probably a random anomaly, I reran it |
On Windows APIs, text is stored in 16-bit wide strings or 8-bit ANSI strings. If you use byte-oriented APIs such as QFile to interact with stdin/stdout/stderr, by default Windows will try to encode text using the ANSI code page. For most users, that's 1252, which cannot represent the characters users typically think of as "Unicode." For backwards compatibility reasons, Windows does not globally switch the ANSI code page to UTF-8, even though UTF-8 has become the de facto 8-bit character encoding.
This PR sets the process code page to UTF-8 for keepassxc-cli.exe (supported since Windows 10 1903) and then ensures that the code page used for console input and output matches the process code page (QTextStream uses the ANSI code page by default and will automatically pick up UTF-8). On older versions of Windows, the code should still work, but only for characters that can be represented by the system ANSI code page.
Fixes #8305
Screenshots
Testing strategy
I added an account to the, previously empty, NonAscii.kbdx file and added a new test that executes the CLI binary to read the password. Unlike the other CLI tests, this one needs to execute the CLI as a separate process because of the way the console interaction works.
Type of change