Well I did not have any luck with that. And doing a search, I found that others before also tried that.
See In Ruby, how to reliably detect a file's encoding (including UTF-16 without BOM)? - Stack Overflow where a responder makes the case that any attempt to “sniff” a text file encoding is unreliable.
Another question (Determining encoding for a file in Ruby - Stack Overflow) had a response about a Ruby gem “rchardet19” with which I also had not very good results. To install this gem from SketchUp’s console, … type:
Gem::install "rchardet19"
After you see all the gem specification spit out, type:
require "rchardet19"
… and lastly:
defined? CharDet
If it is defined the response will be "constant"
.
You can read the gem’s README to know how it works: