Merge pull request #412 from strguntbr/multibyteFix

Fixed substring call
This commit is contained in:
Sean Owen 2015-07-02 17:15:42 +01:00
commit 3b8ab085d8
2 changed files with 7 additions and 1 deletions

View file

@ -215,7 +215,7 @@ final class PDF417HighLevelEncoder {
if (b == 0) { if (b == 0) {
b = 1; b = 1;
} }
byte[] bytes = msg.substring(p, b).getBytes(encoding); byte[] bytes = msg.substring(p, p + b).getBytes(encoding);
if (bytes.length == 1 && encodingMode == TEXT_COMPACTION) { if (bytes.length == 1 && encodingMode == TEXT_COMPACTION) {
//Switch for one byte (instead of latch) //Switch for one byte (instead of latch)
encodeBinary(bytes, 0, 1, TEXT_COMPACTION, sb); encodeBinary(bytes, 0, 1, TEXT_COMPACTION, sb);

View file

@ -36,6 +36,12 @@ public final class PDF417EncoderTestCase extends Assert {
PDF417HighLevelEncoder.encodeHighLevel( PDF417HighLevelEncoder.encodeHighLevel(
"1%§s ?aG$", Compaction.AUTO, StandardCharsets.UTF_8); "1%§s ?aG$", Compaction.AUTO, StandardCharsets.UTF_8);
} }
@Test
public void testEncodeIso88591WithSpecialChars() throws Exception {
// Just check if this does not throw an exception
PDF417HighLevelEncoder.encodeHighLevel("asdfg§asd", Compaction.AUTO, StandardCharsets.ISO_8859_1);
}
@Test @Test
public void testEncodeText() throws Exception { public void testEncodeText() throws Exception {