question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG Encoding string contains '-' character, problem with C40 Encoding

See original GitHub issue

Hi,

I forced using C40 Encoding : context.setForce(true); The problem occurs when i run this test with “Hello-Google” or “–” :

public final class DataMatrixWriterTestCase extends Assert {

  @Test
  public void testDataMatrixImageWriter() {

    Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class);
    hints.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE);
    hints.put(EncodeHintType.FORCE_C40, true);

    int bigEnough = 64;
    DataMatrixWriter writer = new DataMatrixWriter();
    BitMatrix matrix = writer.encode("Hello-Google", BarcodeFormat.DATA_MATRIX, bigEnough, bigEnough, hints);
    assertNotNull(matrix);
    assertTrue(bigEnough >= matrix.getWidth());
    assertTrue(bigEnough >= matrix.getHeight());
  }

i got this error :

> java.lang.IllegalArgumentException: Can't find a symbol arrangement that matches the message. Data codewords: 1559

	at com.google.zxing.datamatrix.encoder.SymbolInfo.lookup(SymbolInfo.java:148)
	at com.google.zxing.datamatrix.encoder.EncoderContext.updateSymbolInfo(EncoderContext.java:136)
	at com.google.zxing.datamatrix.encoder.C40Encoder.encode(C40Encoder.java:39)
	at com.google.zxing.datamatrix.encoder.HighLevelEncoder.encodeHighLevel(HighLevelEncoder.java:194)
	at com.google.zxing.datamatrix.DataMatrixWriter.encode(DataMatrixWriter.java:88)
	at com.google.zxing.datamatrix.DataMatrixWriterTestCase.testDataMatrixImageWriter(DataMatrixWriterTestCase.java:45)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)


Process finished with exit code -1

Thanks!.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
AlexGeller1commented, Jan 25, 2022

I had a deeper look at it. If you are OK with it then I will make a PR for it now.

0reactions
AlexGeller1commented, Jan 26, 2022

Thanks for testing! Very good news that it works. Best regards, Alex

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data Matix C40 encoding - Barcode Forums by Morovia
The "customer content" may contain characters that can't be encoded in C40, or not efficiently encoded in C40.
Read more >
DataMatrix C40 mode is exited unexpectedly #630 - GitHub
We tried to encode the following sample data string: JGB ... there is a service character code 254 ( FE ) that ends...
Read more >
Character is missing in Data Matrix DM C40 and Text Modes
This problem only occurs when encoding certain combinations of upper and lower case letters in C40 or TEXT modes of some Data-Matrix ...
Read more >
How to determine if a String contains invalid encoded characters
Your solution is not going to work. If wrong encoding is used, you will get question marks, instead of exception. Just use my...
Read more >
Gradle compilation fails if source files contain non-ASCII ...
Gradle doesn't warn character encoding and succeeds to build the application. ... +david.perez.ingeniero: From the error message it sounds like your build ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found