Discussions

General J2EE: Printing chineese characters

  1. Printing chineese characters (5 messages)

    Hi all,
       I have problem of printing chinesse characters in POS printer terminal.

        I use Sun java javax.comm package for serial port comuncation.

       Sometimes I am getting correct results, other time it is not. I couldn't identify, How it is going wrong.

       I use port monitor to watch what is happening in t he serial port. It doesn't give any error.

       Any help regarding this will be highly appreciated.

       Thanks advance.

    Regards,
    Murugan

    Threaded Messages (5)

  2. First,check out whether you set the right locale of your application.Just before printing,use System.out.println or other log tools to see what is really sent to the POS printer.If you see the correct Chinese characters,go to the next step.
    Second,check out whether you set the right mode of the printer.To print Chinese character, these directives may be used:
    //select code table
    0x1b t ,
    //select international char
    0x1b R ,
    //select Chinese characters mode
    0x1c & 0x1c C 0x1

    Good luck,
    Albert
  3. Thnaks Albert[ Go to top ]

    Thanks Albert. I don't know how to use printer directives.
    Can you explain more about printer directives and also give web site addresses for reference?


            What is happening here is sometimes it prints perfectly correct. If I try next time, some of the characters not getting printed properly. Instead of single chinese chracter it prints two ascii chars.

    Regards,
    Murugan
  4. As I know, there are a set of JavaPOS APIs above the javax.comm.
    see
    But not all printer manufacturers provide the extended packeage.
    I ever developed programs for one type of EPSON's POS printer and they didn't offer a package for this type.So I read through the printer manuals and used the printer directives directly.
    Just send the directives to the printer using javax.comm
    .SerialPort,something like:
    SerialPort serialPort;
    outputStream = serialPort.getOutputStream();
    outputStream.write(byte[] msg);
    serialPort.close();
    the directive stream is stored in a byte array.
    To make a directive stream is a little complex.
    I think you encountered the different problem as I.
    There may be something wrong with the environment about internationalization. Do you explicitly set(reset) the printer to print Chinese characters?
    >>If I try next time, some of the characters not getting >>printed properly
    Do you mean 你好 is printed like 你RE2W? or all characters are printed incorrect?

    Albert
  5. JavaPOS site[ Go to top ]

    Sorry, I forgot.
    http://www.javapos.com/

    Albert
  6. Thanking you again,[ Go to top ]

    "Do you explicitly set(reset) the printer to print Chinese characters?"

    I don't set anything explicitly.


    "If I try next time, some of the characters not getting >>printed properly
    Do you mean 你好 is printed like 你RE2W? or all characters are printed incorrect?"

    You are correct. Let us say original is like
    开胃菜,湿纸巾
    Correct output is (Ist time): 开胃菜,湿纸巾
    Incorrct output is like(second time) : 开胃菜£╜湿纸╙Θ (for example)
    " (third time) : 开æ£菜,湿纸巾


       What I understood is instead considering double byte characters it is considering a single byte and printing two ascii chars instead of one chinese char.

           In the above example I have 7 chinese characters when it is printed two characters incorrectly, I getting 9 characters.

     
          Thanks for help. I will to set code table and other things then I will see the output.


    Regards,
    Murugan