• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

problem in printing Chinese character on printer

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Marshal
Posts: 79704
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79704
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic