Class | CharDet::CodingStateMachine
In: | lib/tmail/vendor/rchardet-1.3/lib/rchardet/codingstatemachine.rb
Parent: | Object

### Methods

get_coding_state_machine get_current_charlen new next_state reset

### Public Class methods

new(sm)

[Source]

    # File lib/tmail/vendor/rchardet-1.3/lib/rchardet/codingstatemachine.rb, line 31
        def initialize(sm)
          @_mModel = sm
          @_mCurrentBytePos = 0
          @_mCurrentCharLen = 0
          reset()
        end

### Public Instance methods

get_coding_state_machine()

[Source]

    # File lib/tmail/vendor/rchardet-1.3/lib/rchardet/codingstatemachine.rb, line 60
        def get_coding_state_machine
          return @_mModel['name']
        end

get_current_charlen()

[Source]

    # File lib/tmail/vendor/rchardet-1.3/lib/rchardet/codingstatemachine.rb, line 56
        def get_current_charlen
          return @_mCurrentCharLen
        end

next_state(c)

[Source]

    # File lib/tmail/vendor/rchardet-1.3/lib/rchardet/codingstatemachine.rb, line 42
        def next_state(c)
          # for each byte we get its class
          # if it is first byte, we also get byte length
          byteCls = @_mModel['classTable'][c[0]]
          if @_mCurrentState == EStart
            @_mCurrentBytePos = 0
            @_mCurrentCharLen = @_mModel['charLenTable'][byteCls]
          end
          # from byte's class and stateTable, we get its next state
          @_mCurrentState = @_mModel['stateTable'][@_mCurrentState * @_mModel['classFactor'] + byteCls]
          @_mCurrentBytePos += 1
          return @_mCurrentState
        end

reset()

[Source]

    # File lib/tmail/vendor/rchardet-1.3/lib/rchardet/codingstatemachine.rb, line 38
        def reset
          @_mCurrentState = EStart
        end

[Validate]