Class CharDet::Big5DistributionAnalysis
In: lib/tmail/vendor/rchardet-1.3/lib/rchardet/chardistribution.rb
Parent: CharDistributionAnalysis

Methods

get_order   new  

Public Class methods

[Source]

# File lib/tmail/vendor/rchardet-1.3/lib/rchardet/chardistribution.rb, line 165
    def initialize
      super
      @_mCharToFreqOrder = Big5CharToFreqOrder
      @_mTableSize = BIG5_TABLE_SIZE
      @_mTypicalDistributionRatio = BIG5_TYPICAL_DISTRIBUTION_RATIO
    end

Public Instance methods

[Source]

# File lib/tmail/vendor/rchardet-1.3/lib/rchardet/chardistribution.rb, line 172
    def get_order(aStr)
      # for big5 encoding, we are interested 
      #   first  byte range: 0xa4 -- 0xfe
      #   second byte range: 0x40 -- 0x7e , 0xa1 -- 0xfe
      # no validation needed here. State machine has done that
      if aStr[0..0] >= "\xA4"
        if aStr[1..1] >= "\xA1"
          return 157 * (aStr[0] - 0xA4) + aStr[1] - 0xA1 + 63
        else
          return 157 * (aStr[0] - 0xA4) + aStr[1] - 0x40
        end
      else
        return -1
      end
    end

[Validate]