Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/colorls/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ def ls

private

@@encoding = begin # rubocop:disable Style/ClassVars
if ENV['OS'] == 'Windows_NT' && RUBY_PLATFORM !~ /cygwin/
# use UTF-8 to read entries of directories on windows
Encoding::UTF_8
else
Encoding.find('filesystem')
end
end

def init_colors(colors)
@colors = colors
@modes = Hash.new do |hash, key|
Expand All @@ -79,7 +88,7 @@ def init_contents(path)
info = FileInfo.new(path, link_info = @long)

if info.directory?
@contents = Dir.entries(path)
@contents = Dir.entries(path, encoding: @@encoding)

filter_hidden_contents

Expand Down