From d49e5ec03afd09bbcdd703e4fd2faf453dbf686d Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Fri, 28 Jul 2023 14:10:32 +0200 Subject: - decode TLB also in case of wrong non-numeric formating of number values in the bar-code --- src/test/java/org/uic/barcode/test/utils/TestUtils.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/test/java/org') diff --git a/src/test/java/org/uic/barcode/test/utils/TestUtils.java b/src/test/java/org/uic/barcode/test/utils/TestUtils.java index 9791b02..cee5623 100644 --- a/src/test/java/org/uic/barcode/test/utils/TestUtils.java +++ b/src/test/java/org/uic/barcode/test/utils/TestUtils.java @@ -28,6 +28,17 @@ public class TestUtils { } + /* s must be an even-length string. */ + public static byte[] hexStringToByteArray(String s) { + int len = s.length(); + byte[] data = new byte[len / 2]; + for (int i = 0; i < len; i += 2) { + data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + + Character.digit(s.charAt(i+1), 16)); + } + return data; + } + public static Date parseDate (String source){ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); -- cgit v1.2.3