Class: CharDet::EUCTWDistributionAnalysis

Inherits:
CharDistributionAnalysis show all
Defined in:
lib/rchardet/chardistribution.rb

Instance Method Summary collapse

Methods inherited from CharDistributionAnalysis

#confidence, #feed, #got_enough_data, #reset

Constructor Details

#initializeEUCTWDistributionAnalysis

Returns a new instance of EUCTWDistributionAnalysis.



101
102
103
104
105
106
# File 'lib/rchardet/chardistribution.rb', line 101

def initialize
  super()
  @_mCharToFreqOrder = EUCTWCharToFreqOrder
  @_mTableSize = EUCTW_TABLE_SIZE
  @_mTypicalDistributionRatio = EUCTW_TYPICAL_DISTRIBUTION_RATIO
end

Instance Method Details

#order(aStr) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/rchardet/chardistribution.rb', line 108

def order(aStr)
  # for euc-TW encoding, we are interested
  #   first  byte range: 0xc4 -- 0xfe
  #   second byte range: 0xa1 -- 0xfe
  # no validation needed here. State machine has done that
  if aStr[0] >= "\xC4"
    return 94 * (aStr[0].ord - 0xC4) + aStr[1].ord - 0xA1
  else
    return -1
  end
end