Ignore invalid byte sequence in UTF-8

This commit is contained in:
Junegunn Choi 2024-07-22 13:12:54 +09:00
parent c790ab2024
commit e8a39eeb0f
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -71,7 +71,7 @@ if command -v ruby > /dev/null; then
h = {}
i = 0
File.read("/tmp/fzf-bash-history").scan(/^#([0-9]+)$\n(.*?)\n(?=^#[0-9]+$|\z)/m) do |t, c|
File.read("/tmp/fzf-bash-history").encode!("UTF-8", "UTF-8", :invalid => :replace).scan(/^#([0-9]+)$\n(.*?)\n(?=^#[0-9]+$|\z)/m) do |t, c|
next if c.empty?
h.delete(c)
h[c] = [i += 1, t]