1

My goal is to get a code from a 2D barcode read with an Handheld Scanner and to decode it.

The code is compliant with GS1 128. The structure of the code can include "group separator" to separate parts of the code.

I need to read this group separator to identify part of the code.

My problem is : "Group Separator" is the unicode character "GS" hex : 001D, decimal : 29.

It is a non-printing /whitespace character. I can't read it directly from the Scan in java application (I want to have it in a JtextField). GS is removed each time.

I can't read it with InputStream classes using System.in GS is removed each time.

BUT:

If I read a code with notepad++ : GS is not removed. If I copy the code from notepad++ to java app : It works, GS is not removed.

If I read a code with windows console (cmd.exe). It works also.

I can't see where is my issue. I suppose it comes from System.in. I saw it could be done in C++ using std::noskipws format flag.

I give you a example of a code to better understanding : From Notepad++

01211154455215**GS**102254122**GS**125545

img

From windows console :

01211154455215^]102254122^]125545

img2

Thank you for your help

An example of a code I tried :

public class lireCode {
public static String lireCode() throws IOException {

    Scanner s = new Scanner(System.in);
    s.useDelimiter("");
    StringBuilder result =new StringBuilder(); 
    char c;

    do {
    c= s.next().charAt(0);
    if (c==29) {
        c = 41;
    }
    sortie.append(String.valueOf(c));
    }while (s.hasNext());
    s.close();

    return result.toString();
}
}

Here, I try to replace "GS" by ")" to make it legible in the JtextField.

It doesn't work with data from Scan but works with String copy/paste from Notepad++

Flint75
  • 11
  • 3

0 Answers0