Parent

Files

Class/Module Index [+]

Quicksearch

String

Public Instance Methods

detect_encoding(hint_enc=nil) click to toggle source

Attempt to detect the encoding of this string

Returns: a Hash with :encoding, :language, :type and :confidence

# File lib/charlock_holmes/string.rb, line 7
def detect_encoding(hint_enc=nil)
  encoding_detector.detect(self, hint_enc)
end
detect_encoding!(hint_enc=nil) click to toggle source

Attempt to detect the encoding of this string then set the encoding to what was detected ala `force_encoding`

Returns: self

# File lib/charlock_holmes/string.rb, line 25
def detect_encoding!(hint_enc=nil)
  if detected = self.detect_encoding(hint_enc)
    self.force_encoding detected[:encoding]
  end
  self
end
detect_encodings(hint_enc=nil) click to toggle source

Attempt to detect the encoding of this string, and return a list with all the possible encodings that match it.

Returns: an Array with zero or more Hashes,

each one of them with with :encoding, :language, :type and :confidence
# File lib/charlock_holmes/string.rb, line 16
def detect_encodings(hint_enc=nil)
  encoding_detector.detect_all(self, hint_enc)
end

Protected Instance Methods

encoding_detector() click to toggle source
# File lib/charlock_holmes/string.rb, line 34
def encoding_detector
  @encoding_detector ||= CharlockHolmes::EncodingDetector.new
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.