4
4

3 回答 3

6

在 Java 1.6 中,您可以使用System.console()而不是 System.out.println() 来向控制台显示重音字符。

public class Test2 {
  public static void main(String args[]){
   String s = "caractères français :  à é \u00e9"; // Unicode for "é"
   System.out.println(s);
   System.console().writer().println(s);
  }
}

输出是

C:\temp>java Test
caractþres franþais :  Ó Ú Ú
caractères français :  à é é

另请参阅将重音字符输出到控制台

于 2013-04-12T11:20:09.587 回答
3

Use unicode escaped sequence: \u00E8

System.err.println("Param\u00E8tre manquant. … ");

Here's an useful Unicode character table.

于 2013-04-12T10:49:13.910 回答
1

Try using \u<XXXX> when encoding unicode characters. It won't look pretty in code, but it will work and be portable.

For instance:

String specialCharacters= "\u00E1 \u00E9 \u00ED \u00F3 \u00FA";
System.out.println(specialCharacters); // This will print á é í ó ú

Check Alepac's answer for a table of unicode characters.

于 2013-04-12T10:50:12.053 回答