Skip to content

Commit f68017d

Browse files
committed
[windows/vim] Encode batchfile in current codepage
Backport junegunn/vim-plug#913
1 parent 2b725a4 commit f68017d

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

plugin/fzf.vim

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,14 @@ if s:is_win
4949

5050
" Use utf-8 for fzf.vim commands
5151
" Return array of shell commands for cmd.exe
52+
let s:codepage = libcallnr('kernel32.dll', 'GetACP', 0)
5253
function! s:wrap_cmds(cmds)
53-
let use_chcp = executable('sed')
5454
return map([
5555
\ '@echo off',
5656
\ 'setlocal enabledelayedexpansion']
57-
\ + (use_chcp ? [
58-
\ 'for /f "usebackq" %%a in (`chcp ^| sed "s/[^0-9]//gp"`) do set origchcp=%%a',
59-
\ 'chcp 65001 > nul'] : [])
6057
\ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds])
61-
\ + (use_chcp ? ['chcp !origchcp! > nul'] : [])
6258
\ + ['endlocal'],
63-
\ 'v:val."\r"')
59+
\ printf('iconv(v:val."\r", "%s", "cp%d")', &encoding, s:codepage))
6460
endfunction
6561
else
6662
let s:term_marker = ";#FZF"

0 commit comments

Comments
 (0)