class CharDet::SJISDistributionAnalysis
Public Class Methods
new()
click to toggle source
Calls superclass method
CharDet::CharDistributionAnalysis::new
# File lib/rchardet/chardistribution.rb, line 201 def initialize super() @charToFreqOrder = JISCharToFreqOrder @tableSize = JIS_TABLE_SIZE @typicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO end
Public Instance Methods
get_order(aStr)
click to toggle source
# File lib/rchardet/chardistribution.rb, line 208 def get_order(aStr) # for sjis encoding, we are interested # first byte range: 0x81 -- 0x9f , 0xe0 -- 0xfe # second byte range: 0x40 -- 0x7e, 0x81 -- oxfe # no validation needed here. State machine has done that bytes = aStr.bytes.to_a if (aStr[0, 1] >= "\x81") and (aStr[0, 1] <= "\x9F") order = 188 * (bytes[0] - 0x81) elsif (aStr[0, 1] >= "\xE0") and (aStr[0, 1] <= "\xEF") order = 188 * (bytes[0] - 0xE0 + 31) else return -1 end order = order + bytes[1] - 0x40 if aStr[1, 1] > "\x7F" order =- 1 end return order end