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

Use chcp only if sed is in PATH #891

Merged
merged 1 commit into from
Oct 14, 2019
Merged

Use chcp only if sed is in PATH #891

merged 1 commit into from
Oct 14, 2019

Conversation

janlazo
Copy link
Collaborator

@janlazo janlazo commented Oct 13, 2019

Fix #884

sed is now required to parse chcp output. Vim can be used instead via separate child system call but doing it per s:system makes Windows slower. chcp parsing is fragile because of the system locale. There's no convenient way to parse out the codepage value without regex just by relying on cmd.exe builtins and default binaries in PATH.
If this still doesn't work, users will have to get by with ascii output only (no readable unicode symbols from console) because this is a OS problem. This applies to fzf as well because the chcp code orignated from fzf Vim plugin was meant for UTF-8 characters.

Powershell builtins could be used as an alternative to sed but using powershell on non-powershell &shell slows down s:system.

\ ]
\ 'setlocal enabledelayedexpansion']
\ + (use_chcp ? [
\ 'for /f "usebackq" %%a in (`chcp ^| sed "s/[^0-9]//gp"`) do set origchcp=%%a',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes that the first numeric token is the codepage.

@janlazo janlazo merged commit fcfd5b7 into master Oct 14, 2019
@janlazo janlazo deleted the chcp-sed branch October 14, 2019 11:55
junegunn added a commit to junegunn/fzf that referenced this pull request Nov 2, 2019
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.

chcp parsing is wrong for German locale
1 participant