0

I'm running my Java program from Unix. To simplify matters, I describe only the relevant part.

public static void main(String[] args) {  
    System.out.println("féminin");  
} 

My output is garbage. It is obviously a character-encoding problem, the French character é is not showing up correctly. I've tried the following:

public static void main(String[] args) {  
    PrintStream ps = new PrintStream(System.out, true, "ISO-8859-1");  
    ps.println("féminin");  
} 

But my output is still showing ? in palce of french character.
I ran the sam efile in command prompt with java -Dfile.encoding=IBM437 DSIClient féminin
it worked fine. But How can I resolve this character-encoding issue with Unix? Thanks

user1912935
  • 361
  • 4
  • 13
  • 34

1 Answers1

1

The problem is most likely that your code editor and your terminal emulator use different encodings, and Java's notion of the default encoding may in addition be different.

To see if your terminal and your editor agree, you could simply cat your java source file. Does the é show up correctly? If so, you use the same encoding in your source code editor and your terminal, but it is not Java's default encoding. If, OTOH, you can't see the é, you need to find out what encoding is used by your terminal and your editor and brind them in agreement.

Ingo
  • 36,037
  • 5
  • 53
  • 100
  • how to find the coding of terminal – user1912935 Sep 23 '13 at 10:17
  • @user1912935 It depends. UNIX has so many terminal emulations. If I right click in my terminal window, I get a menu, and one of the sub-menus is "Character Encoding". This is "Konsole" on Suse Linux. – Ingo Sep 23 '13 at 12:42