Class: CharDet::EUCJPContextAnalysis

Inherits:
JapaneseContextAnalysis show all
Defined in:
lib/tmail/vendor/rchardet-1.3/lib/rchardet/jpcntx.rb

Instance Method Summary collapse

Methods inherited from JapaneseContextAnalysis

#feed, #get_confidence, #got_enough_data, #initialize, #reset

Constructor Details

This class inherits a constructor from CharDet::JapaneseContextAnalysis

Instance Method Details

#get_order(aStr) ⇒ Object


207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/tmail/vendor/rchardet-1.3/lib/rchardet/jpcntx.rb', line 207

def get_order(aStr)
  return -1, 1 unless aStr
  # find out current char's byte length
  aStr = aStr[0..1].join if aStr.class == Array
  if (aStr[0..0] == "\x8E") or ((aStr[0..0] >= "\xA1") and (aStr[0..0] <= "\xFE"))
    charLen = 2
  elsif aStr[0..0] == "\x8F"
    charLen = 3
  else
    charLen = 1
  end

  # return its order if it is hiragana
  if aStr.length > 1
    if (aStr[0..0] == "\xA4") and (aStr[1..1] >= "\xA1") and (aStr[1..1] <= "\xF3")
      return aStr[1] - 0xA1, charLen
    end
  end

  return -1, charLen
end