Skip to content

Conversation

dnoneill
Copy link
Contributor

@dnoneill dnoneill commented Sep 4, 2025

No description provided.

return mimetype unless mimetype.starts_with?('text')

content = File.read(current_file.path)
encoding = content.encoding.name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Encoding is a property of the environment, not the file.

for example:

➜ ruby -e 'p File.read("Gemfile").encoding'
#<Encoding:UTF-8>
➜  ruby -E ISO-8859-1 -e 'p File.read("Gemfile").encoding'
#<Encoding:ISO-8859-1>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, there may be multiple valid encodings that overlap (as is true in this file with UTF-8 and ISO-8859-1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants