mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Now more lenient in detecting Shift_JIS to detect more byte sequences as Shift_JIS
git-svn-id: https://zxing.googlecode.com/svn/trunk@662 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
a8b57c466d
commit
70732c334e
|
@ -264,7 +264,7 @@ final class DecodedBitStreamParser {
|
||||||
// the Shift_JIS encoding
|
// the Shift_JIS encoding
|
||||||
if (lastWasPossibleDoubleByteStart) {
|
if (lastWasPossibleDoubleByteStart) {
|
||||||
// If we just checked this and the last byte for being a valid double-byte
|
// If we just checked this and the last byte for being a valid double-byte
|
||||||
// char, don't check starting on this byte. If the this and the last byte
|
// char, don't check starting on this byte. If this and the last byte
|
||||||
// formed a valid pair, then this shouldn't be checked to see if it starts
|
// formed a valid pair, then this shouldn't be checked to see if it starts
|
||||||
// a double byte pair of course.
|
// a double byte pair of course.
|
||||||
lastWasPossibleDoubleByteStart = false;
|
lastWasPossibleDoubleByteStart = false;
|
||||||
|
@ -273,6 +273,13 @@ final class DecodedBitStreamParser {
|
||||||
// double byte pair encoding a character.
|
// double byte pair encoding a character.
|
||||||
lastWasPossibleDoubleByteStart = true;
|
lastWasPossibleDoubleByteStart = true;
|
||||||
int nextValue = bytes[i + 1] & 0xFF;
|
int nextValue = bytes[i + 1] & 0xFF;
|
||||||
|
if (nextValue < 0x40 || nextValue > 0xFC) {
|
||||||
|
return UTF8;
|
||||||
|
}
|
||||||
|
// There is some conflicting information out there about which bytes can follow which in
|
||||||
|
// double-byte Shift_JIS characters. The rule above seems to be the one that matches practice.
|
||||||
|
// The stricter rule below, however, is given by other resources.
|
||||||
|
/*
|
||||||
if ((value & 0x1) == 0) {
|
if ((value & 0x1) == 0) {
|
||||||
// if even, next value should be in [0x9F,0xFC]
|
// if even, next value should be in [0x9F,0xFC]
|
||||||
// if not, we'll guess UTF-8
|
// if not, we'll guess UTF-8
|
||||||
|
@ -286,6 +293,7 @@ final class DecodedBitStreamParser {
|
||||||
return UTF8;
|
return UTF8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue