diff --git a/case-study-porting-chardet-to-python-3.html b/case-study-porting-chardet-to-python-3.html index e433412..9bc8ed7 100755 --- a/case-study-porting-chardet-to-python-3.html +++ b/case-study-porting-chardet-to-python-3.html @@ -613,9 +613,9 @@ TypeError: unorderable types: int() >= str()
In this case, there’s no need to make the code more complicated by adding an explicit coercion. aStr[0] yields an integer; the things you’re comparing to are all constants. Let’s change them from 1-character strings to integers. And while we’re at it, let’s change aStr to aBuf, since it’s not actually a string.
class SJISContextAnalysis(JapaneseContextAnalysis):
- def get_order(self, aStr):
-- if not aStr: return -1, 1
+- if not aStr: return -1, 1
+ def get_order(self, aBuf):
-+ if not aBuf: return -1, 1
++ if not aBuf: return -1, 1
# find out current char's byte length
- if ((aStr[0] >= '\x81') and (aStr[0] <= '\x9F')) or \
- ((aBuf[0] >= '\xE0') and (aBuf[0] <= '\xFC')):
@@ -626,12 +626,12 @@ TypeError: unorderable types: int() >= str()
charLen = 1
# return its order if it is hiragana
-