Additional fix for issue #300 (HT micjahn)

This commit is contained in:
Sean Owen 2015-02-06 21:39:28 +00:00
parent 4b02337709
commit 625d9b77d7
2 changed files with 9 additions and 2 deletions

View file

@ -73,10 +73,11 @@ final class X12Encoder extends C40Encoder {
int available = context.getSymbolInfo().getDataCapacity() - context.getCodewordCount();
int count = buffer.length();
context.pos -= count;
if (context.getRemainingCharacters() != 1 || available != 1) {
if (context.getRemainingCharacters() > 1 || available > 1 ||
context.getRemainingCharacters() != available) {
context.writeCodeword(HighLevelEncoder.X12_UNLATCH);
}
if (count > 0) {
if (context.getNewEncoding() < 0) {
context.signalEncoderChange(HighLevelEncoder.ASCII_ENCODATION);
}
}

View file

@ -325,6 +325,12 @@ public final class HighLevelEncodeTestCase extends Assert {
assertEquals("238 9 10 104 141 254 50 129", visualized);
}
@Test
public void testX12Unlatch2() {
String visualized = encodeHighLevel("*DTCP0");
assertEquals("238 9 10 104 141", visualized);
}
@Test
public void testBug3048549() {
//There was an IllegalArgumentException for an illegal character here because