Class: CharDet::UTF8Prober
Instance Attribute Summary
#active
Instance Method Summary
collapse
#filter_high_bit_only, #filter_with_english_letters, #filter_without_english_letters, #result, #state
Constructor Details
Returns a new instance of UTF8Prober.
Instance Method Details
#charset_name ⇒ Object
45
46
47
|
# File 'lib/rchardet/utf8prober.rb', line 45
def charset_name
return "UTF-8"
end
|
#confidence ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/rchardet/utf8prober.rb', line 75
def confidence
unlike = 0.99
if @_mNumOfMBChar < 6
(0...@_mNumOfMBChar).each do
unlike *= ONE_CHAR_PROB
end
return 1.0 - unlike
else
return unlike
end
end
|
#feed(aBuf) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/rchardet/utf8prober.rb', line 49
def feed(aBuf)
aBuf.each_byte do |b|
c = b.chr
codingState = @_mCodingSM.next_state(c)
if codingState == EError
@_mState = ENotMe
break
elsif codingState == EItsMe
@_mState = EFoundIt
break
elsif codingState == EStart
if @_mCodingSM.current_charlen >= 2
@_mNumOfMBChar += 1
end
end
end
if state == EDetecting
if confidence > SHORTCUT_THRESHOLD
@_mState = EFoundIt
end
end
return state
end
|
#reset ⇒ Object
39
40
41
42
43
|
# File 'lib/rchardet/utf8prober.rb', line 39
def reset
super()
@_mCodingSM.reset()
@_mNumOfMBChar = 0
end
|