Parent

Class/Module Index [+]

Quicksearch

CharDet::UTF8Prober

Public Class Methods

new() click to toggle source
# File lib/tmail/vendor/rchardet-1.3/lib/rchardet/utf8prober.rb, line 33
def initialize
  super()
  @_mCodingSM = CodingStateMachine.new(UTF8SMModel)
  reset()
end

Public Instance Methods

feed(aBuf) click to toggle source
# File lib/tmail/vendor/rchardet-1.3/lib/rchardet/utf8prober.rb, line 49
def feed(aBuf)
  aBuf.each_byte do |b|
    c = b.chr
    codingState = @_mCodingSM.next_state(c)
    if codingState == EError
      @_mState = ENotMe
      break
    elsif codingState == EItsMe
      @_mState = EFoundIt
      break
    elsif codingState == EStart
      if @_mCodingSM.get_current_charlen() >= 2
        @_mNumOfMBChar += 1
      end
    end
  end

  if get_state() == EDetecting
    if get_confidence() > SHORTCUT_THRESHOLD
      @_mState = EFoundIt
    end
  end

  return get_state()
end
get_charset_name() click to toggle source
# File lib/tmail/vendor/rchardet-1.3/lib/rchardet/utf8prober.rb, line 45
def get_charset_name
  return "utf-8"
end
get_confidence() click to toggle source
# File lib/tmail/vendor/rchardet-1.3/lib/rchardet/utf8prober.rb, line 75
def get_confidence
  unlike = 0.99
  if @_mNumOfMBChar < 6
    for i in (0...@_mNumOfMBChar)
      unlike = unlike * ONE_CHAR_PROB
    end
    return 1.0 - unlike
  else
    return unlike
  end
end
reset() click to toggle source
# File lib/tmail/vendor/rchardet-1.3/lib/rchardet/utf8prober.rb, line 39
def reset
  super()
  @_mCodingSM.reset()
  @_mNumOfMBChar = 0
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.