Class: CharDet::EUCKRDistributionAnalysis

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

#initializeEUCKRDistributionAnalysis

Returns a new instance of EUCKRDistributionAnalysis.



122
123
124
125
126
127
# File 'lib/rchardet/chardistribution.rb', line 122

def initialize
  super()
  @_mCharToFreqOrder = EUCKRCharToFreqOrder
  @_mTableSize = EUCKR_TABLE_SIZE
  @_mTypicalDistributionRatio = EUCKR_TYPICAL_DISTRIBUTION_RATIO
end

Instance Method Details

#order(aStr) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
# File 'lib/rchardet/chardistribution.rb', line 129

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