class CharDet::EscCharSetProber

Public Class Methods

new() click to toggle source
Calls superclass method CharDet::CharSetProber::new
# File lib/rchardet/escprober.rb, line 31
def initialize
  super()
  @codingSM = [ 
                 CodingStateMachine.new(HZSMModel),
                 CodingStateMachine.new(ISO2022CNSMModel),
                 CodingStateMachine.new(ISO2022JPSMModel),
                 CodingStateMachine.new(ISO2022KRSMModel)
                ]
  reset()
end

Public Instance Methods

feed(aBuf) click to toggle source
# File lib/rchardet/escprober.rb, line 65
def feed(aBuf)
  aBuf.each_byte do |b|
    c = b.chr
    for codingSM in @codingSM
      next unless codingSM
      next unless codingSM.active
      codingState = codingSM.next_state(c)
      if codingState == EError
        codingSM.active = false
        @activeSM -= 1
        if @activeSM <= 0
          @state = ENotMe
          return get_state()
        end
      elsif codingState == EItsMe
        @state = EFoundIt
        @detectedCharset = codingSM.get_coding_state_machine()
        return get_state()
      end
    end
  end

  return get_state()
end
get_charset_name() click to toggle source
# File lib/rchardet/escprober.rb, line 53
def get_charset_name
  return @detectedCharset
end
get_confidence() click to toggle source
# File lib/rchardet/escprober.rb, line 57
def get_confidence
  if @detectedCharset
    return 0.99
  else
    return 0.00
  end
end
reset() click to toggle source
Calls superclass method CharDet::CharSetProber#reset
# File lib/rchardet/escprober.rb, line 42
def reset
  super()
  for codingSM in @codingSM
    next if !codingSM
    codingSM.active = true
    codingSM.reset()
  end
  @activeSM = @codingSM.length
  @detectedCharset = nil
end