/usr/lib/ruby/vendor_ruby/charlock_holmes/string.rb is in ruby-charlock-holmes 0.6.9.4.dfsg1-1+b4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | require 'charlock_holmes' unless defined? CharlockHolmes
class String
# Attempt to detect the encoding of this string
#
# Returns: a Hash with :encoding, :language, :type and :confidence
def detect_encoding(hint_enc=nil)
detector = CharlockHolmes::EncodingDetector.new
detector.detect(self, hint_enc)
end
# 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
def detect_encodings(hint_enc=nil)
detector = CharlockHolmes::EncodingDetector.new
detector.detect_all(self, hint_enc)
end
if RUBY_VERSION =~ /1.9/
# Attempt to detect the encoding of this string
# then set the encoding to what was detected ala `force_encoding`
#
# Returns: self
def detect_encoding!(hint_enc=nil)
if detected = self.detect_encoding(hint_enc)
self.force_encoding(detected[:encoding]) if detected[:encoding]
end
self
end
end
end
|