Class CharDet::EscCharSetProber
In: lib/tmail/vendor/rchardet-1.3/lib/rchardet/escprober.rb
Parent: CharSetProber

Methods

Public Class methods

[Source]

# File lib/tmail/vendor/rchardet-1.3/lib/rchardet/escprober.rb, line 31
    def initialize
      super()
      @_mCodingSM = [ 
        CodingStateMachine.new(HZSMModel),
        CodingStateMachine.new(ISO2022CNSMModel),
        CodingStateMachine.new(ISO2022JPSMModel),
        CodingStateMachine.new(ISO2022KRSMModel)
      ]
      reset()
    end

Public Instance methods

[Source]

# File lib/tmail/vendor/rchardet-1.3/lib/rchardet/escprober.rb, line 65
    def feed(aBuf)
      aBuf.each_byte do |b|
        c = b.chr
        for codingSM in @_mCodingSM
          next unless codingSM
          next unless codingSM.active
          codingState = codingSM.next_state(c)
          if codingState == EError
            codingSM.active = false
            @_mActiveSM -= 1
            if @_mActiveSM <= 0
              @_mState = ENotMe
              return get_state()
            end
          elsif codingState == EItsMe
            @_mState = EFoundIt
            @_mDetectedCharset = codingSM.get_coding_state_machine()
            return get_state()
          end
        end
      end

      return get_state()
    end

[Source]

# File lib/tmail/vendor/rchardet-1.3/lib/rchardet/escprober.rb, line 53
    def get_charset_name
      return @_mDetectedCharset
    end

[Source]

# File lib/tmail/vendor/rchardet-1.3/lib/rchardet/escprober.rb, line 57
    def get_confidence
      if @_mDetectedCharset
        return 0.99
      else
        return 0.00
      end
    end

[Source]

# File lib/tmail/vendor/rchardet-1.3/lib/rchardet/escprober.rb, line 42
    def reset
      super()
      for codingSM in @_mCodingSM:
        next if not codingSM
        codingSM.active = true
        codingSM.reset()
      end
      @_mActiveSM = @_mCodingSM.length
      @_mDetectedCharset = nil
    end

[Validate]