Skip to content

Commit

Permalink
✨ Support cp850 encoding for auto-completion in PowerShell (#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
svlandeg authored Nov 18, 2024
1 parent 03ea87a commit 14cac70
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions typer/_completion_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ def install_powershell(*, prog_name: str, complete_var: str, shell: str) -> Path
if isinstance(result.stdout, str): # pragma: no cover
path_str = result.stdout
if isinstance(result.stdout, bytes):
try:
# PowerShell would be predominant in Windows
path_str = result.stdout.decode("windows-1252")
except UnicodeDecodeError: # pragma: no cover
for encoding in ["windows-1252", "utf8", "cp850"]:
try:
path_str = result.stdout.decode("utf8")
except UnicodeDecodeError:
click.echo("Couldn't decode the path automatically", err=True)
raise
path_str = result.stdout.decode(encoding)
break
except UnicodeDecodeError: # pragma: no cover
pass
if not path_str: # pragma: no cover
click.echo("Couldn't decode the path automatically", err=True)
raise click.exceptions.Exit(1)
path_obj = Path(path_str.strip())
parent_dir: Path = path_obj.parent
parent_dir.mkdir(parents=True, exist_ok=True)
Expand Down

0 comments on commit 14cac70

Please sign in to comment.