Class: CharDet::GB2312DistributionAnalysis
- Inherits:
-
CharDistributionAnalysis
- Object
- CharDistributionAnalysis
- CharDet::GB2312DistributionAnalysis
- Defined in:
- lib/rchardet/chardistribution.rb
Instance Method Summary collapse
-
#initialize ⇒ GB2312DistributionAnalysis
constructor
A new instance of GB2312DistributionAnalysis.
- #order(aStr) ⇒ Object
Methods inherited from CharDistributionAnalysis
#confidence, #feed, #got_enough_data, #reset
Constructor Details
#initialize ⇒ GB2312DistributionAnalysis
Returns a new instance of GB2312DistributionAnalysis.
143 144 145 146 147 148 |
# File 'lib/rchardet/chardistribution.rb', line 143 def initialize super() @_mCharToFreqOrder = GB2312CharToFreqOrder @_mTableSize = GB2312_TABLE_SIZE @_mTypicalDistributionRatio = GB2312_TYPICAL_DISTRIBUTION_RATIO end |
Instance Method Details
#order(aStr) ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/rchardet/chardistribution.rb', line 150 def order(aStr) # for GB2312 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") and (aStr[1] >= "\xA1") return 94 * (aStr[0].ord - 0xB0) + aStr[1].ord - 0xA1 else return -1 end end |