class CharDet::Big5DistributionAnalysis

Public Class Methods

new() click to toggle source
Calls superclass method CharDet::CharDistributionAnalysis::new
# File lib/rchardet/chardistribution.rb, line 175
def initialize
  super
  @charToFreqOrder = Big5CharToFreqOrder
  @tableSize = BIG5_TABLE_SIZE
  @typicalDistributionRatio = BIG5_TYPICAL_DISTRIBUTION_RATIO
end

Public Instance Methods

get_order(aStr) click to toggle source
# File lib/rchardet/chardistribution.rb, line 182
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, 1] >= "\xA4"
    bytes = aStr.bytes.to_a
    if aStr[1, 1] >= "\xA1"
      return 157 * (bytes[0] - 0xA4) + bytes[1] - 0xA1 + 63
    else
      return 157 * (bytes[0] - 0xA4) + bytes[1] - 0x40
    end
  else
    return -1
  end
end