wood burning stoves 2.0*
The moose likes Java in General and the fly likes Java Cyrillic Characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Cyrillic Characters" Watch "Java Cyrillic Characters" New topic
Author

Java Cyrillic Characters

Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Hi

I have a java code thats prints text files fine without any issues. But I tried to print some cyrillic and greek characters, but its printing some junk characters and I tried the same using wordpad its printing fine.

Whether java is trying to print using own font set ? How to change that ?


Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Cyrillic and Greek fonts are installein my machine..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37913
    
  22
You mean printing on paper, not on the command line?
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Yes printing on paper.. I posted the printing code in my previous post.. Please help me out on this
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37913
    
  22
Don't know, sorry.

I think this is too difficult a question for the beginners. Moving.
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Any suggestions will be appreciated.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Google for Joel on Software unicode article, it will tell you why this is happening.... basically you need to ensure that the character encoding is supported internally within your javacode, externally by any viewers/OS and externally by print drivers etc


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
Martijn Verburg wrote:Google for Joel on Software unicode article, it will tell you why this is happening.... basically you need to ensure that the character encoding is supported internally within your javacode, externally by any viewers/OS and externally by print drivers etc


You mean this: http://www.joelonsoftware.com/articles/Unicode.html

Good luck!
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
I guess nothing related to my issue.

even this too http://www.freeutils.net/source/jcharset/
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Instead of using DocFlavor.INPUT_STREAM.AUTOSENSE, you need to actually specify the character encoding of the data. For example, if your file is stored as UTF-8, use DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_8 . AUTOSENSE isn't going to figure this out by itself. It definitely doesn't care about character encoding.


[Jess in Action][AskingGoodQuestions]
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Ernest thanks for the reply. I have a file that contains cyrillic characetrs and the file is stored as a text file only. even I tried with all options of DocFlavor.INPUT_STREAM

public static final INPUT_STREAM TEXT_PLAIN_HOST;
public static final INPUT_STREAM TEXT_PLAIN_UTF_8 = new INPUT_STREAM("text/plain; charset=utf-8");
public static final INPUT_STREAM TEXT_PLAIN_UTF_16 = new INPUT_STREAM("text/plain; charset=utf-16");
public static final INPUT_STREAM TEXT_PLAIN_UTF_16BE = new INPUT_STREAM("text/plain; charset=utf-16be");
public static final INPUT_STREAM TEXT_PLAIN_UTF_16LE = new INPUT_STREAM("text/plain; charset=utf-16le");
public static final INPUT_STREAM TEXT_PLAIN_US_ASCII = new INPUT_STREAM("text/plain; charset=us-ascii");

Any other suggestions please
 
 
subject: Java Cyrillic Characters
 
Similar Threads
To print pdf file
Landscape Printing
Java Language Print
help in java printing
help in java printing