GetText::RubyParser

Public Instance Methods

detect_encoding(source) click to toggle source
# 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 /\A.*coding\s*[=:]\s*([[:alnum:]\-_]+)/ =~ binary_source
    $1.gsub(/-(?:unix|mac|dos)\z/, "")
  else
    nil
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.