# File lib/gettext/tools/parser/ruby.rb, line 133 def detect_encoding(source) return nil unless source.respond_to?(:force_encoding) binary_source = source.dup.force_encoding("ASCII-8BIT") if %r\A.*coding\s*[=:]\s*([[:alnum:]\-_]+)/ =~ binary_source $1.gsub(%r-(?:unix|mac|dos)\z/, "") else nil end end