Permalink
Browse files

Fixed the compatible problem with Rails

The $KCODE settings in Rails caused the String#split works differently
from what was expected. Replaced it to String#each_byte and solved the
problem.
  • Loading branch information...
1 parent a4bfd27 commit d0f14f3ea54979b0d7eb079b0f1803f3987deb74 @windix windix committed Jul 17, 2009
Showing with 8 additions and 4 deletions.
  1. +2 −1 lib/rchardet/escprober.rb
  2. +2 −1 lib/rchardet/latin1prober.rb
  3. +2 −1 lib/rchardet/sbcharsetprober.rb
  4. +2 −1 lib/rchardet/utf8prober.rb
@@ -63,7 +63,8 @@ def get_confidence
end
def feed(aBuf)
- for c in aBuf.split('')
+ aBuf.each_byte do |b|
+ c = b.chr
for codingSM in @_mCodingSM
next unless codingSM
next unless codingSM.active
@@ -109,7 +109,8 @@ def get_charset_name
def feed(aBuf)
aBuf = filter_with_english_letters(aBuf)
- for c in aBuf.split('')
+ aBuf.each_byte do |b|
+ c = b.chr
charClass = Latin1_CharToClass[c[0]]
freq = Latin1ClassModel[(@_mLastCharClass * CLASS_NUM) + charClass]
if freq == 0
@@ -71,7 +71,8 @@ def feed(aBuf)
if not aLen
return get_state()
end
- for c in aBuf.split('')
+ aBuf.each_byte do |b|
+ c = b.chr
order = @_mModel['charToOrderMap'][c[0]]
if order < SYMBOL_CAT_ORDER
@_mTotalChar += 1
@@ -47,7 +47,8 @@ def get_charset_name
end
def feed(aBuf)
- for c in aBuf.split('')
+ aBuf.each_byte do |b|
+ c = b.chr
codingState = @_mCodingSM.next_state(c)
if codingState == EError
@_mState = ENotMe

0 comments on commit d0f14f3

Please sign in to comment.