Skip to content

powershell: fix non-ASCII character corruption in tab completion on Windows#2401

Open
pb2004 wants to merge 1 commit into
spf13:mainfrom
pb2004:patch-1
Open

powershell: fix non-ASCII character corruption in tab completion on Windows#2401
pb2004 wants to merge 1 commit into
spf13:mainfrom
pb2004:patch-1

Conversation

@pb2004
Copy link
Copy Markdown

@pb2004 pb2004 commented May 11, 2026

Problem

On Windows, [Console]::OutputEncoding defaults to the system OEM code page
rather than UTF-8. This causes non-ASCII characters in remote/path names to be
corrupted after tab completion.

Example: Zażółć becomes Za┼╝├│┼é─ç

Reported in rclone/rclone#9412 (rclone uses cobra-generated completions).

Fix

Temporarily switch [Console]::OutputEncoding to UTF-8 around the completion
command invocation and restore it afterwards — the same pattern already used
in the generated script for other purposes.

Testing

Tested on Windows PowerShell 5.1 with Polish diacritics in path names.

…indows

On Windows, [Console]::OutputEncoding defaults to the system OEM code page rather than UTF-8, causing non-ASCII characters (e.g. Polish diacritics) in remote path names to be corrupted after tab completion — resulting in garbled output like "Za┼╝├│┼é─ç" instead of "Zażółć".

Fix by temporarily switching [Console]::OutputEncoding to UTF-8 around the completion command invocation and restoring it afterwards.

Fixes: rclone/rclone#9412
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 11, 2026

CLA assistant check
All committers have signed the CLA.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants