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

On Windows keepassxc-cli.exe changes the code page to 65001 but does not restore it. #11465

Open
smru opened this issue Nov 13, 2024 · 3 comments · May be fixed by #11470
Open

On Windows keepassxc-cli.exe changes the code page to 65001 but does not restore it. #11465

smru opened this issue Nov 13, 2024 · 3 comments · May be fixed by #11470
Assignees
Milestone

Comments

@smru
Copy link

smru commented Nov 13, 2024

Overview

When calling keepassxc-cli.exe on Windows it changes the code page to 65001.
And when calling powershell.exe, the font changes from Consolas to Raster Fonts.
Version 2.7.3 is OK, but versions 2.7.4 and later change the code page and the console font.

Steps to Reproduce

  1. Open Command Prompt.
  2. Set console font to Consolas, size 16.
  3. Type: powershell.exe dir C:\Windows\System32\cmd.exe
  4. Console font doesn't change.
  5. Type: "C:\Program Files\KeePassXC\keepassxc-cli.exe" -v
  6. Console font doesn't change.
  7. Type: powershell.exe dir C:\Windows\System32\cmd.exe
  8. Console font changes to Raster Fonts, size 8x12.

Expected Behavior

Console font does not change.

Actual Behavior

Console font changes from Consolas, size 16 to Raster Fonts, size 8x12.

Context

Default code page is 850, not 437.
The chcp.com command returns 850.
The Command Prompt font is set to Consolas, size 16.

KeePassXC - 2.7.4 and later

Operating System: Windows

Additional info when running inside PowerShell.

# Compile a helper type that calls the WinAPI functions.
Add-Type -Namespace Util -Name WinApi -MemberDefinition @'
    [DllImport("Kernel32.dll")]
    public static extern uint GetACP();
    [DllImport("Kernel32.dll")]
    public static extern uint GetOEMCP();
    [DllImport("Kernel32.dll")]
    public static extern uint GetConsoleCP();
    [DllImport("Kernel32.dll")]
    public static extern uint GetConsoleOutputCP();
'@
[Util.WinAPI]::GetACP()			# Returns 1252
[Util.WinAPI]::GetOEMCP()		# Returns 850
[Util.WinAPI]::GetConsoleCP()		# Returns 850
[Util.WinAPI]::GetConsoleOutputCP()	# Returns 850
 & 'C:\Program Files\KeePassXC\keepassxc-cli.exe' -v	# Returns 2.7.9
[Util.WinAPI]::GetACP()			# Returns 1252
[Util.WinAPI]::GetOEMCP()		# Returns 850
[Util.WinAPI]::GetConsoleCP()		# Returns 65001
[Util.WinAPI]::GetConsoleOutputCP()	# Returns 850

@smru smru added the bug label Nov 13, 2024
@droidmonkey
Copy link
Member

droidmonkey commented Nov 13, 2024

The default code page is 437 when I launch a fresh command prompt. I do not observe any font changes from within Terminal, but I do observe that from the legacy command prompt.

@smru
Copy link
Author

smru commented Nov 14, 2024

Steps to Reproduce on fresh Windows 10 Enterprise 22H2 installation.

  • Open Command Prompt.
  • Default console font is Consolas with size 16.
  • Type chcp and press Enter. It returns 437.
  • Type powershell.exe dir C:\Windows\System32\cmd.exe and press Enter. Console font does not change.
  • Type chcp and press Enter. It returns 437.
  • Type "C:\Program Files\KeePassXC\keepassxc-cli.exe" -v and press Enter. It return 2.7.9. Console font does not change.
  • Type chcp and press Enter. It returns 65001.
  • Type powershell.exe dir C:\Windows\System32\cmd.exe and press Enter. Console font changes to Raster Fonts.

When opening a new Command Prompt and changing the console font from Consolas to Lucida Console.
and trying to reproduce the issue, the code page does change to 65001, but the font remains Lucida Console.

@phoerious
Copy link
Member

This is so we can display passwords with non-ASCII characters. See #3050.

@phoerious phoerious removed the bug label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: To triage
Development

Successfully merging a pull request may close this issue.

3 participants