• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in printing Chinese character on printer  RSS feed

 
mannu shukla
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When i am using below code to print chinese character, its printing some garbage value.
Please suggest how to print chinese character using printer.

public void printOutput (ArrayList outContent)
{

try
{
String PrinterPort = "LPT1:"; \\ can use com1,com2 etc
PrintWriter bufWr = new PrintWriter(PrinterPort, "UTF-8");
for (int i=0;i<outContent.size();i++)
{
if (outContent.get(i)!=null )
{
bufWr.write(outContent.get(i) + "");
bufWr.write("\n");
}
}

bufWr.flush();
bufWr.close();
System.out.println("print out completed");
}
catch (Exception e) {
}

}



Regards
Ashish Shukla>
 
Campbell Ritchie
Marshal
Posts: 56533
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use the code button and never use an empty "catch."

I think that question too difficult for us beginners. Moving.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens when you print to stdout, is that the character you're expecting?
 
mannu shukla
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's printing some garbage character when i am using System.out.println().

I will follow Campbell advise for further queries..

Thanks



 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so you need to think about encoding and for that I strongly recommend reading Joel's article on encoding.
 
Campbell Ritchie
Marshal
Posts: 56533
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And remember some terminals only handle a very restricted range of characters. DOS/Windows handles far fewer characters than *nix shells.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!