This commit is contained in:
Dmitry Shirokov 2013-08-12 12:11:54 +10:00
parent 9fd949edf3
commit 26054b56e7
1 changed files with 18 additions and 17 deletions

View File

@ -266,25 +266,26 @@ module.exports.big5 = function() {
this.nextChar = function(iter, det) {
iter.index = iter.nextIndex;
iter.error = false;
var firstByte;
firstByte = iter.charValue = iter.nextByte(det);
if (firstByte < 0) {
var firstByte = iter.charValue = iter.nextByte(det);
if (firstByte < 0)
return false;
}
if (firstByte <= 0x7f || firstByte == 0xff) {
// single byte character.
if (firstByte <= 0x7f || firstByte == 0xff)
return true;
}
var secondByte = iter.nextByte(det);
if (secondByte < 0) {
if (secondByte < 0)
return false;
}
iter.charValue = (iter.charValue << 8) | secondByte;
if (secondByte < 0x40 ||
secondByte == 0x7f ||
secondByte == 0xff) {
if (secondByte < 0x40 || secondByte == 0x7f || secondByte == 0xff)
iter.error = true;
}
return true;
};
};
@ -350,7 +351,7 @@ function eucNextChar(iter, det) {
}
}
}
return (iter.done == false);
return iter.done == false;
};
@ -479,7 +480,7 @@ module.exports.gb_18030 = function() {
break buildChar;
}
}
return (iter.done == false);
return iter.done == false;
};
// TODO: This set of data comes from the character frequency-