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

Non ASCII chars are not shown fzf #26

Closed
mrkingmidas opened this issue Oct 25, 2024 · 7 comments
Closed

Non ASCII chars are not shown fzf #26

mrkingmidas opened this issue Oct 25, 2024 · 7 comments
Labels
bug Something isn't working external The issue is external from clink-fzf question Further information is requested

Comments

@mrkingmidas
Copy link

mrkingmidas commented Oct 25, 2024

Hello!

Non ASCII chars are not shown fzf:
There is a description of the solution in Can't input non ascii characters #3799 - specify --no-height and it works, but only for an independent call in cmd.

If I set fzf.height = in clink_settings and SET FZF_DEFAULT_OPTS=--no-height, then pressing Ctrl+T does not work. In the task manager com. the line "fzf.exe" --reverse --scheme=path --no-height -i -m - if called directly, it works correctly.

My knowledge of lua is extremely low, apparently the problem is somewhere in the code

local r = io.popen(command..' 2>nul | '..get_fzf('path')..' -i -m')

I use ConEmu on Windows 10.

Add:
In command=dir /b /s /a:d-s $dir that returns in codepage=866

@mrkingmidas
Copy link
Author

I am find ugly solution with iconv.exe:

In my startup bat script set:

SET FZF_DEFAULT_OPTS=--no-height
SET FZF_CTRL_T_COMMAND=dir_utf8 /b /s /a:-s $dir
SET FZF_ALT_C_COMMAND=dir_utf8 /b /s /a:d-s $dir

and in PATH place dir_utf8.bat with:

@DIR %* | iconv -c -f 866 -t utf-8           

@chrisant996
Copy link
Owner

I don't think this is related to clink-fzf.

But Clink uses utf8.

And since fzf is a *nix app cross-compiled for Windows, fzf probably uses utf8.

Read the section icons in fzf which mentions the dirx program and its --utf8 flag.

@chrisant996 chrisant996 added question Further information is requested external The issue is external from clink-fzf labels Oct 25, 2024
@mrkingmidas
Copy link
Author

I don't think this is related to clink-fzf.

But Clink uses utf8.

And since fzf is a *nix app cross-compiled for Windows, fzf probably uses utf8.

Read the section icons in fzf which mentions the dirx program and its --utf8 flag.

Thank you!

Now with dirx --utf8 work:

SET FZF_DEFAULT_OPTS=--no-height
SET FZF_CTRL_T_COMMAND=dirx --utf8 /b /s /a:-s $dir
SET FZF_ALT_C_COMMAND=dirx --utf8 /b /s /a:d-s $dir

@chrisant996
Copy link
Owner

I'll add some text in the README about fzf's utf8 expectation. Maybe I can even find a way to allow configuring whether clink-fzf's fzf.lua script should convert from system code page to utf8, to compensate.

But really the fzf program itself would benefit from a flag to control code page conversion. If no such flag exists in the fzf program, then what would be a gap in the Windows cross-compiled version of fzf itself.

@chrisant996
Copy link
Owner

chrisant996 commented Oct 26, 2024

Maybe I can even find a way to allow configuring whether clink-fzf's fzf.lua script should convert from system code page to utf8, to compensate.

There isn't a good way for the fzf.lua script to convert the input, because it isn't even involved.

An important feature of fzf is that it lets you search even before all the content has been loaded. For example, you can immediately start searching even while a long-running dir /s /b c:\ command is running. For that feature to work, there needs to be an external program feeding content to fzf, such as the dir command. The fzf.lua script can't just scan the drive, give the file names to fzf, and then let the user type -- because that would be very slow and would defeat the asynchronous searching capabilities of fzf.

But really the fzf program itself would benefit from a flag to control code page conversion. If no such flag exists in the fzf program, then what would be a gap in the Windows cross-compiled version of fzf itself.

I opened junegunn/fzf#4065 for that, and I also commented on junegunn/fzf#3799. Both are Windows-specific issues; 4065 is about processing redirected stdin, and 3799 is about processing direct keyboard input.

I'll add some text in the README about fzf's utf8 expectation.

Done (here).

@chrisant996
Copy link
Owner

Closing this issue. The clink-fzf documentation now covers the FZF known issues about Unicode content. The rest of what's discussed here lies in FZF itself and is tracked by the FZF issues cited above.

@chrisant996
Copy link
Owner

chrisant996 commented Oct 29, 2024

I've made changes in fzf.lua to automatically add a chcp 65001 workaround, and to restore the original codepage afterwards.

That should eliminate the need for adding custom user-configured workarounds.

(See commit 76a76a1.)

@chrisant996 chrisant996 added the bug Something isn't working label Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working external The issue is external from clink-fzf question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants