kelleyma49 / PSFzf

A PowerShell wrapper around the fuzzy finder fzf
MIT License
750 stars 35 forks source link

Incorrect Unicode when using CTRL+T #260

Closed Flat closed 3 months ago

Flat commented 3 months ago

When using CTRL+T and selecting a file with Japanese characters the returned path is incorrect.

As an example #Robomeme 😿😱ミャーーー 素材配布 #hololive #ホロライブ #猫ミーム [q5WTgxw8Trw].webm becomes #Robomeme 仭亞繝溘Ε繝シ繝シ繝シ 邏譚宣・蟶・#hololive #繝帙Ο繝ゥ繧、繝・#迪ォ繝溘・繝 [q5WTgxw8Trw].webm

fzftest

owenstake commented 3 months ago

The stdin/stdout of fzf is regonized/encoded as utf8, same as all unix tool like ripgrep, fdfind. But the default stdin/stdout encoding for windows tool and powershell scripts is unicode(utf16-LE). So piping get-childitem to fzf, it will result as incorrect unicode for CJK. You may need to set the encoding to utf8 by

$InputEncoding = $OutputEncoding =
        [Console]::OutputEncoding = [Console]::InputEncoding =
        [System.Text.Encoding]::utf8
Flat commented 3 months ago

Looks like that was indeed the issue... Thank you.