用JAVA编写client端,现在要向C语言编写server发送一些字符串,英文的可以,但是发送中文C端就会报错,求助! 5
代码:publicstaticvoidmain(String[]args){try{InetAddressip=InetAddress.getByName("192.16...
代码:public static void main(String[] args) {
try {
InetAddress ip = InetAddress.getByName("192.168.6.1");
int port=8084;
InetSocketAddress socketAddress=new InetSocketAddress(ip,port);
Socket socket = new Socket();
socket.connect(socketAddress);
PrintWriter out = new PrintWriter(new OutputStreamWriter
(socket.getOutputStream(),"UTF-8"), true);
out.print(str);
out.close();
socket.close();
}catch (UnknownHostException e1) {
e1.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}
}
其实就是乱码问题,但是不知道怎么解决... 有高手啊??? 展开
try {
InetAddress ip = InetAddress.getByName("192.168.6.1");
int port=8084;
InetSocketAddress socketAddress=new InetSocketAddress(ip,port);
Socket socket = new Socket();
socket.connect(socketAddress);
PrintWriter out = new PrintWriter(new OutputStreamWriter
(socket.getOutputStream(),"UTF-8"), true);
out.print(str);
out.close();
socket.close();
}catch (UnknownHostException e1) {
e1.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}
}
其实就是乱码问题,但是不知道怎么解决... 有高手啊??? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询