我正在努力解决字符集问题。我运行带有java.net.Socket.Socket连接和JavaFX客户端的Java Server。我(当前)在双方都使用PrintWriter和BufferedReader进行通信。但是,当我发送诸如“ÄÄÄ”之类的东西并将其发送到服务器上的控制台时,我得到“Ã?Ã?Ã?”。我的代码是这样的:
//on both sides ... also tried with UTF_8 - result was also like this
writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.UTF_16));
reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_16));
//client writes
writer.write("ÄÄÄ");
writer.flush();
//... and reads
line = reader.readLine()
//server the same
要正确发送德语的爱慕乐或带有重音符号的字母,我应该怎么做?