Skip to content

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

Closed
@smru

Description

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

Activity

droidmonkey

droidmonkey commented on Nov 13, 2024

@droidmonkey
Member

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.

added this to the v2.7.10 milestone on Nov 13, 2024
self-assigned this
on Nov 13, 2024
added a commit that references this issue on Nov 13, 2024
d8d4c62
smru

smru commented on Nov 14, 2024

@smru
Author

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

phoerious commented on Nov 16, 2024

@phoerious
Member

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

added a commit that references this issue on Dec 1, 2024
fd5b533

3 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

Projects

  • Status

    Done

Relationships

None yet

Development

No branches or pull requests

Issue actions

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