Cygwin encoding difficulties

后端 未结 1 692
孤街浪徒
孤街浪徒 2021-01-15 16:27

Not sure whether this is a programming problem. I began to suspect so... but then I ran the Java program (executable jar) in question in a Windows console instead of a Cygwi

相关标签:
1条回答
  • 2021-01-15 16:56

    Thanks to Paul and Zhong Yu for the answers here.

    To print to Cygwin do this sort of thing:

    PrintStream out = new PrintStream(System.out, true, "UTF-8");
    out.print( outputString );
    

    To read from Cygwin do this sort of thing:

    BufferedReader br = new BufferedReader( new InputStreamReader(System.in, "UTF-8") );
    String nextInputLine = br.readLine();
    

    Slightly amazed that this question has not come up before re Cygwin.

    0 讨论(0)
提交回复
热议问题